A034175 a(n) is minimal such that a(n)+a(n-1) is a square and a(n) is not in {a(0), ..., a(n-1)}.
0, 1, 3, 6, 10, 15, 21, 4, 5, 11, 14, 2, 7, 9, 16, 20, 29, 35, 46, 18, 31, 33, 48, 52, 12, 13, 23, 26, 38, 43, 57, 24, 25, 39, 42, 22, 27, 37, 44, 56, 8, 17, 19, 30, 34, 47, 53, 28, 36, 45, 55, 66, 78, 91, 105, 64, 80, 41, 40, 60, 61, 83, 86, 58, 63, 81, 88, 108, 117, 79, 65
Offset: 0
Links
- Zak Seidov and P. Pein, Table of n, a(n) for n = 0..10000
- Ely Golden, Python program
- Index entries for sequences that are permutations of the natural numbers
Programs
-
Maple
N:= 1000: # to go up to the first term > N B:= Vector(N): a[0]:= 0: found:= true: for n from 1 while found do found:= false: for k from floor(sqrt(a[n-1]))+1 do b:= k^2 - a[n-1]; if b > N then a[n]:= b; break fi; if B[b] = 0 then found:= true; a[n]:= b; B[b]:= 1; break fi od od: seq(a[i],i=0..n-1); # Robert Israel, Jun 02 2015
-
Mathematica
a[ 0 ]=b[ 0 ]=0; lst={0}; For[ n=1, n<250, n++, For[ s=Ceiling[ Sqrt[ a[ n-1 ] ] ], MemberQ[ lst, s^2-a[ n-1 ] ], s++, Null ]; b[ a[ n ]=s^2-a[ n-1 ] ]=n; AppendTo[ lst, a[ n ] ] ]; Table[ a[ n ], {n, 0, 100} ] (* Second program: *) lst = {}; f[s_List] := Block[{k = 1, l = s[[ -1]]}, While[ MemberQ[s, k] || !IntegerQ@ Sqrt[k + l], k++ ]; AppendTo[lst, k]]; Nest[f, lst, 100] (* Robert G. Wilson v, May 09 2010 *)
-
PARI
my(v=List(0), vs = vecsort(Vec(v)), n=1); while(n<50, if(issquare(v[#v]+n) && !vecsearch(vs, n), listput(v, n); vs = vecsort(Vec(v)); n=0); n++); Vec(v) \\ Derek Orr, Jun 01 2015; edited by Michel Marcus, Jan 04 2022
Comments