In this challenge we'll compute an infinite minimal admissible sequence.
The sequence for this challenge starts with a(1) = 1
.
We continue this sequence by finding a(n)
as the smallest possible number such that a(n) > a(n-1)
and for every prime p
, the set {a(i) mod p : 1 ≤ i ≤ n}
has at most p-1
elements.
Write a program or function that takes positive integer n
and outputs a(n)
. Shortest code in bytes wins.
Example:
a(6)
is 19
, rather than, say 17
because [1,3,7,9,13,19]
(the previous terms) is admissible while [1,3,7,9,13,17]
is not.
[1,3,7,9,13,17]
is not admissible, because for the base 3
, after taking the modulo of each term with 3
, we obtain [1,0,1,0,1,2]
which contains every non-negative number smaller than 3
, our chosen base.
For [1,3,7,9,13,19]
however, it would be impossible to come up with a base such that the list after modulo contains every non-negative integer smaller than such base.
Reference:
Testcases:
a(1) = 1
a(2) = 3
a(3) = 7
a(4) = 9
a(5) = 13
a(6) = 19
a(7) = 21
a(8) = 27
a(9) = 31
a(10) = 33
a(100) = 583