%I #30 Feb 22 2022 20:57:18
%S 1,2,3,4,9,13,16,25,36,49,64,81,100,121,144,169,196,225,256,289,324,
%T 361,400,441,484,529,576,625,676,729,784,841,900,961,1024,1089,1156,
%U 1225,1296,1369,1444,1521,1600,1681,1764,1849,1936,2025,2116,2209,2304
%N a(1)=1; thereafter a(n+1) is the least k > a(n) such that k is a square mod a(i) for all i<= n.
%C For 7 <= n < 10^12.5, a(n) = (n-3)^2. On the ERH this holds for all n >= 7; unconditionally it holds for all but finitely many n. - _Charles R Greathouse IV_, Mar 29 2012
%C a(n) is the smallest integer larger than a(n-1) such that a(n) is a quadratic residuum modulo all a(i), 1<=i<n. - _R. J. Mathar_, Jul 27 2015
%H Reinhard Zumkeller, <a href="/A034793/b034793.txt">Table of n, a(n) for n = 1..500</a>
%F Apparently includes all positive squares along with 2, 3 and 13.
%p A034793 := proc(n)
%p option remember;
%p local a,wrks ;
%p if n = 1 then
%p 1;
%p else
%p for a from procname(n-1)+1 do
%p wrks := true;
%p for i from 1 to n-1 do
%p if numtheory[quadres](a,procname(i)) <> 1 then
%p wrks := false;
%p break;
%p end if;
%p end do;
%p if wrks then
%p return a;
%p end if;
%p end do:
%p end i # _R. J. Mathar_, Jul 27 2015
%t a[n_ ] := If[n<7, {1, 2, 3, 4, 9, 13}[[n]], (n-3)^2]; Table[a[n], {n, 1, 60}] (* _Jean-François Alcover_, Jul 22 2015, after _Charles R Greathouse IV_ *)
%o (Haskell)
%o a034793 n = a034793_list !! (n-1)
%o a034793_list = 1 : f [2..] [1] where
%o f (x:xs) ys | and $ map (isSquMod x) ys = x : f xs (x:ys)
%o | otherwise = f xs ys
%o isSquMod u v = u `mod` v `elem` (map ((`mod` v) . (^ 2)) [0..v-1])
%o -- _Reinhard Zumkeller_, Mar 27 2012
%o (PARI) a(n)=if(n<7,[1,2,3,4,9,13][n],(n-3)^2) \\ _Charles R Greathouse IV_, Mar 29 2012
%Y Cf. A034903, A054762.
%K nonn,nice
%O 1,2
%A _David W. Wilson_
%E More precise definition from _Giovanni Resta_, Jul 22 2015
|