OFFSET
1,2
COMMENTS
a(n) is the smallest integer larger than a(n-1) such that all a(i), 1<=i<n, are quadratic residues mod a(n). - R. J. Mathar, Jul 27 2015
MAPLE
A034791 := proc(n)
option remember;
local a, wrks ;
if n = 1 then
1;
else
for a from procname(n-1)+1 do
wrks := true;
for i from 1 to n-1 do
if numtheory[quadres](procname(i), a) <> 1 then
wrks := false;
end if;
end do;
if wrks then
return a;
end if;
end do:
end if;
end proc: # R. J. Mathar, Jul 27 2015
MATHEMATICA
residueQ[n_, k_] := Length[Select[Range[Floor[k/2]], PowerMod[#, 2, k] == n &, 1]] == 1; a[1] = 1; a[n_] := a[n] = For[r = Range[n - 1]; an = a[n - 1] + 1, True, an++, If[AllTrue[r, residueQ[a[#], an] &], Return[an]]]; Table[Print["a(", n, ") = ", a[n]]; a[n], {n, 1, 37}] (* Jean-François Alcover, Feb 16 2018 *)
PROG
(Haskell)
a034791 n = a034791_list !! (n-1)
a034791_list = 1 : f [2..] [1] where
f (x:xs) ys | and $ map (flip isSquMod x) ys = x : f xs (x:ys)
| otherwise = f xs ys
isSquMod u v = u `mod` v `elem` (map ((`mod` v) . (^ 2)) [0..v-1])
-- Reinhard Zumkeller, fixed Jul 29 2015, Mar 28 2012
CROSSREFS
KEYWORD
nonn
AUTHOR
STATUS
approved