OFFSET
1,2
COMMENTS
a(1) = 1 and for n>1: a(n) = smallest m not occurring earlier such that m^2 + a(n-1)^2 is a prime; the primes are in A100209.
Note the same parity of a(n) and n for all terms. [Zak Seidov, Apr 27 2011]
Subsequence s(1..m) is a permutation of the natural numbers 1..m only for m=1,2,3. [Zak Seidov, Apr 28 2011]
All filtering primes (A100209) are distinct because primes of the form 4k+1 have a unique representation as the sum of two squares. [Zak Seidov, Apr 28 2011]
LINKS
MATHEMATICA
nn = 100; unused = Range[2, nn]; t = {1}; While[k = 0; While[k++; k <= Length[unused] && ! PrimeQ[t[[-1]]^2 + unused[[k]]^2]]; k <= Length[unused], AppendTo[t, unused[[k]]]; unused = Delete[unused, k]]; t (* T. D. Noe, Apr 27 2011 *)
PROG
(Haskell)
import Data.Set (singleton, notMember, insert)
a100208 n = a100208_list !! (n-1)
a100208_list = 1 : (f 1 [1..] $ singleton 1) where
f x (w:ws) s
| w `notMember` s &&
a010051 (x*x + w*w) == 1 = w : (f w [1..] $ insert w s)
| otherwise = f x ws s where
-- Reinhard Zumkeller, Apr 28 2011
(Python)
from sympy import isprime
A100208 = [1]
for n in range(1, 100):
a, b = 1, 1 + A100208[-1]**2
while not isprime(b) or a in A100208:
b += 2*a+1
a += 1
A100208.append(a) # Chai Wah Wu, Sep 01 2014
(PARI) v=[1]; n=1; while(n<100, if(isprime(v[#v]^2+n^2)&&!vecsearch(vecsort(v), n), v=concat(v, n); n=0); n++); v \\ Derek Orr, Jun 01 2015
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Reinhard Zumkeller, Nov 08 2004
STATUS
approved