A100208 Minimal permutation of the natural numbers such that the sum of squares of two consecutive terms is a prime.
1, 2, 3, 8, 5, 4, 9, 10, 7, 12, 13, 20, 11, 6, 19, 14, 15, 22, 17, 18, 23, 30, 29, 16, 25, 24, 35, 26, 21, 34, 39, 40, 33, 28, 37, 32, 27, 50, 31, 44, 41, 46, 49, 36, 65, 38, 45, 52, 57, 68, 43, 42, 55, 58, 47, 48, 53, 62, 73, 60, 61, 54, 59, 64, 71, 66, 79, 56, 51, 76, 85, 72
Offset: 1
Links
Crossrefs
Programs
-
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
-
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 *)
-
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
-
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
Comments