%I #33 Mar 21 2023 12:09:44
%S 0,3,4,0,3,4,4,3,0,4,3,5,5,3,4,0,3,4,4,3,8,4,3,7,0,3,4,5,3,4,4,3,5,4,
%T 3,0,5,3,4,7,3,4,4,3,7,4,3,5,0,3,4,5,3,4,4,3,5,4,3,9,7,3,4,0,3,4,4,3,
%U 7,4,3,5,5,3,4,7,3,4,4,3,0,4,3,9,8,3,4,5,3,4,4,3,5,4,3,7,5,3,4,0,3,4,4,3,9
%N If n is a square, a(n) is 0. Otherwise, a(n) is the smallest number k such that n is not a quadratic residue modulo k.
%C I.e., if n is not a square, a(n) is the smallest number d for which a sequence that has a common difference of d contains n but that has no squares.
%C All nonzero values in this sequence are at least 3.
%C All nonzero values are prime powers, and every prime power except 2 appears in the sequence. This can be proved using the Chinese remainder theorem. - _Franklin T. Adams-Watters_, Jun 10 2011
%C Records of nonzero values in this sequence are in A066730.
%H Dan Uznanski, <a href="/A139401/b139401.txt">Table of n, a(n) for n = 1..10000</a>
%e a(2) = 3 because there are no squares in the sequence 2, 5, 8, 11, 14, 17, 20, ...
%o (Python)
%o import math
%o def A139401(n):
%o if int(math.sqrt(n)) == math.sqrt(n):
%o return 0
%o for pp in range(2, n + 2): # only really need to check prime powers
%o residues = frozenset(pow(k, 2, pp) for k in range(pp))
%o if n % pp not in residues:
%o return pp # _Dan Uznanski_, Jun 22 2021
%o (PARI) a(n) = if (issquare(n), 0, my(k=2); while (issquare(Mod(n, k)), k++); k); \\ _Michel Marcus_, Jun 25 2021
%Y Cf. A066730, A100867, A144294, A354597.
%K nonn
%O 1,2
%A _J. Lowell_, Jun 09 2008, Jun 10 2008
%E More terms from _John W. Layman_, Jun 17 2008
%E New name from _Franklin T. Adams-Watters_, Jun 10 2011
|