OFFSET
1,2
COMMENTS
Sequence is a permutation of the positive integers.
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..1000
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
Andy Martin, Apr 18 2008
EXTENSIONS
More terms from Robert G. Wilson v, May 31 2009
STATUS
approved