A258742 With a(1) = 1, a(n) is the smallest positive number not already in the sequence such that a(n)^2 + a(n-1)^2 is not prime.
1, 3, 4, 2, 6, 7, 5, 9, 8, 10, 11, 12, 14, 13, 15, 16, 17, 19, 18, 20, 21, 22, 24, 23, 25, 27, 26, 28, 29, 31, 32, 30, 33, 34, 36, 37, 35, 38, 39, 41, 40, 42, 44, 43, 45, 46, 47, 49, 48, 50, 52, 51, 53, 54, 55, 56, 57, 58, 59, 60, 62, 61, 63, 64, 65, 67, 66, 68, 69, 71, 72, 70, 73, 74, 75, 76, 77, 78, 79, 81
Offset: 1
Keywords
Programs
-
Mathematica
f[n_] := Block[{a = {1}, k}, For[k = 2, k <= n, k++, i = 1; While[Or[PrimeQ[i^2 + a[[k - 1]]^2], MemberQ[a, i]], i++]; AppendTo[a, i]]; a]; f@ 120 (* Michael De Vlieger, Jun 10 2015 *)
-
PARI
v=[1]; n=1; while(n<100, if(!isprime(n^2+v[#v]^2)&&!vecsearch(vecsort(v), n), v=concat(v, n); n=0); n++); v
Comments