OFFSET
3,1
COMMENTS
The sequence reaches 2 infinitely many times as a(4n)=2. (If we had a(4n)>=3, it would imply a(4)>=3, but a(4)=2. This comes from the fact that a(m*n)<=a(m) for m,n>=3.
LINKS
Tom Hejda, Table of n, a(n) for n = 3..20000
MathOverflow user Seva, Consecutive non-quadratic residues (Proves that a(n) is unbounded.)
EXAMPLE
For n=17 we have residues {0,1,2,4,8,9,13,15,16} and the following arithmetic progressions of length 5: (15, 16, 0, 1, 2), (13, 15, 0, 2, 4), (9, 13, 0, 4, 8)
PROG
(SageMath)
def a(n) :
if n in [1, 2] : return Infinity
R = quadratic_residues(n)
return max( next( m for m in itertools.count() if (a+(b-a)*m)%n not in R ) \
for a, b in zip(R, R[1:]+R[:1]) if gcd(b-a, n) == 1 )
CROSSREFS
KEYWORD
nonn
AUTHOR
Tom Hejda, Nov 27 2017
STATUS
approved