cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A377212 a(n) is the least number k that is not a quadratic residue modulo prime(n) but is a quadratic residue modulo all previous primes.

This page as a plain text file.
%I A377212 #19 Oct 21 2024 18:26:43
%S A377212 2,3,6,21,15,91,246,429,1005,399,3094,3045,21099,41155,43059,404754,
%T A377212 214230,569130,182919,2190279,860574,9361374,8042479,33440551,
%U A377212 36915670,11993466,287638530,182528031,697126530,78278655,3263415285,6941299170,25856763139,32968406926,13803374706
%N A377212 a(n) is the least number k that is not a quadratic residue modulo prime(n) but is a quadratic residue modulo all previous primes.
%C A377212 a(n) = A000037(j) for the least j such that A144294(j) = prime(n).
%C A377212 Such numbers k exist for all n >= 2: for example, if x is a quadratic nonresidue modulo prime(n), by the Chinese Remainder Theorem there exists k such that k == x (mod prime(n)) and k == 1 (mod prime(j)) for 1 <= j < n.
%e A377212 a(4) = 6 because 6 is not a quadratic residue modulo 7, but is a quadratic residue modulo 2, 3, and 5, and no smaller number works.
%p A377212 f:= proc(n) local k,p;
%p A377212   if issqr(n) then return -1 fi;
%p A377212   p:= 1;
%p A377212   for k from 1 do
%p A377212       p:= nextprime(p);
%p A377212       if numtheory:-quadres(n,p) = -1 then return k fi
%p A377212   od
%p A377212 end proc:
%p A377212 V:= Array(2..32): count:= 0:
%p A377212 for k from 2 while count < 31 do
%p A377212   v:= f(k);
%p A377212 if v > 0 and v <= 32 and V[v] = 0 then
%p A377212   V[v]:= k; count:= count+1
%p A377212 fi
%p A377212 od:
%p A377212 convert(V,list);
%o A377212 (Python)
%o A377212 from itertools import count
%o A377212 from math import isqrt
%o A377212 from sympy.ntheory import prime, nextprime, legendre_symbol
%o A377212 def A377212(n):
%o A377212     p = prime(n)
%o A377212     for r in count(1):
%o A377212         k, q = r+(m:=isqrt(r))+(r>=m*(m+1)+1), 2
%o A377212         while (q:=nextprime(q)):
%o A377212             if q>p or legendre_symbol(k,q)==-1:
%o A377212                 break
%o A377212         if p==q:
%o A377212             return k # _Chai Wah Wu_, Oct 20 2024
%Y A377212 Cf. A000037, A096636, A144294, A144295.
%K A377212 nonn
%O A377212 2,1
%A A377212 _Robert Israel_, Oct 19 2024
%E A377212 a(33)-a(36) from _Chai Wah Wu_, Oct 21 2024