|
|
A137442
|
|
n^2 followed by smallest integer not yet listed.
|
|
3
|
|
|
1, 2, 4, 3, 9, 5, 16, 6, 25, 7, 36, 8, 49, 10, 64, 11, 81, 12, 100, 13, 121, 14, 144, 15, 169, 17, 196, 18, 225, 19, 256, 20, 289, 21, 324, 22, 361, 23, 400, 24, 441, 26, 484, 27, 529, 28, 576, 29, 625, 30, 676, 31, 729, 32, 784, 33, 841, 34, 900, 35, 961, 37, 1024, 38
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
COMMENTS
|
Sequence is a permutation of the positive integers.
|
|
LINKS
|
|
|
FORMULA
|
Formula, generating two terms for every m: m^2, m + round(sqrt(m)).
IFTE(n mod 2 ==1, ((n+1)/2)^2, (n/2)+round(sqrt(n/2),0)). - Gerald Hillier, Nov 15 2010
|
|
MATHEMATICA
|
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 *)
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 *)
|
|
PROG
|
(Ruby)
# correct to any term:
sk_ct = 2
skip = 4
at = 1
(1..(1.0/0)).each{ |i|
if (at+=1) == skip
at+=1
sk_ct +=1
skip = sk_ct * sk_ct
end
print i*i, " ", at, " "
}
(Ruby)
# Simpler Ruby code, correct until i is so large that floating point rounding causes errors. I estimate this will be before i reaches 10000000000000000
(1..(1.0/0)).each{ |i|
print i*i, " ", i + (Math.sqrt(i) + 0.5).to_i, " "
}
(PARI) lista(nn) = {for (n=1, nn, print1(n^2, ", ", n+round(sqrt(n)), ", "); ); } \\ Michel Marcus, Nov 02 2014
(PARI) a(n) = if (n % 2, ((n+1)/2)^2, (n/2)+round(sqrt(n/2))); \\ Michel Marcus, Nov 02 2014
|
|
CROSSREFS
|
|
|
KEYWORD
|
easy,nonn
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|