%I #44 May 28 2023 08:46:29
%S 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,
%T 23,26,38,43,57,24,25,39,42,22,27,37,44,56,8,17,19,30,34,47,53,28,36,
%U 45,55,66,78,91,105,64,80,41,40,60,61,83,86,58,63,81,88,108,117,79,65
%N 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)}.
%C Conjectured to be a permutation of the nonnegative integers.
%H Zak Seidov and P. Pein, <a href="/A034175/b034175.txt">Table of n, a(n) for n = 0..10000</a>
%H Ely Golden, <a href="/A034175/a034175.py.txt">Python program</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%p N:= 1000: # to go up to the first term > N
%p B:= Vector(N):
%p a[0]:= 0:
%p found:= true:
%p for n from 1 while found do
%p found:= false:
%p for k from floor(sqrt(a[n-1]))+1 do
%p b:= k^2 - a[n-1];
%p if b > N then a[n]:= b; break fi;
%p if B[b] = 0 then
%p found:= true;
%p a[n]:= b;
%p B[b]:= 1;
%p break
%p fi
%p od
%p od:
%p seq(a[i],i=0..n-1); # _Robert Israel_, Jun 02 2015
%t 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} ]
%t (* Second program: *)
%t 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 *)
%o (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
%Y Cf. A064928, A064929, A064930.
%K nonn,easy,nice
%O 0,3
%A _Dean Hickerson_, Oct 01 1998
|