login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A137442 n^2 followed by smallest integer not yet listed. 3

%I #30 Nov 03 2014 03:28:22

%S 1,2,4,3,9,5,16,6,25,7,36,8,49,10,64,11,81,12,100,13,121,14,144,15,

%T 169,17,196,18,225,19,256,20,289,21,324,22,361,23,400,24,441,26,484,

%U 27,529,28,576,29,625,30,676,31,729,32,784,33,841,34,900,35,961,37,1024,38

%N n^2 followed by smallest integer not yet listed.

%C Sequence is a permutation of the positive integers.

%H Harvey P. Dale, <a href="/A137442/b137442.txt">Table of n, a(n) for n = 1..1000</a>

%F Formula, generating two terms for every m: m^2, m + round(sqrt(m)).

%F IFTE(n mod 2 ==1, ((n+1)/2)^2, (n/2)+round(sqrt(n/2),0)). - _Gerald Hillier_, Nov 15 2010

%t f[s_List] := Block[{k = 1}, While[ MemberQ[s, k], k++ ]; Flatten@ Append[s, {((2 + Length@s)/2)^2, k}]]; Nest[f, {1, 2}, 33] (* _Robert G. Wilson v_, May 31 2009 *)

%t Module[{nn=40,sq,int,len},sq=Range[nn]^2;int=Complement[Range[nn],sq];len=Min[Length[int],nn];Riffle[Take[sq,len],Take[int,len]]](* _Harvey P. Dale_, Nov 05 2013 *)

%o (Ruby)

%o # correct to any term:

%o sk_ct = 2

%o skip = 4

%o at = 1

%o (1..(1.0/0)).each{ |i|

%o if (at+=1) == skip

%o at+=1

%o sk_ct +=1

%o skip = sk_ct * sk_ct

%o end

%o print i*i, " ", at, " "

%o }

%o (Ruby)

%o # Simpler Ruby code, correct until i is so large that floating point rounding causes errors. I estimate this will be before i reaches 10000000000000000

%o (1..(1.0/0)).each{ |i|

%o print i*i, " ", i + (Math.sqrt(i) + 0.5).to_i, " "

%o }

%o (PARI) lista(nn) = {for (n=1, nn, print1(n^2, ", ", n+round(sqrt(n)), ", "););} \\ _Michel Marcus_, Nov 02 2014

%o (PARI) a(n) = if (n % 2, ((n+1)/2)^2, (n/2)+round(sqrt(n/2))); \\ _Michel Marcus_, Nov 02 2014

%Y Cf. A000463.

%K easy,nonn

%O 1,2

%A _Andy Martin_, Apr 18 2008

%E More terms from _Robert G. Wilson v_, May 31 2009

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 18 07:06 EDT 2024. Contains 375255 sequences. (Running on oeis4.)