OFFSET
0,3
COMMENTS
The term a(n) is either n+1 or a square. All the squares appear and they appear in increasing order. Every other term is a square, except when the index is a square, in which case, the corresponding term is also a square (which shifts the pattern). See FORMULA for a more precise statement.
FORMULA
To define a(n), let k = floor(sqrt(n)). Then a(n) = n+1 if n-k^2 is odd and ((n+k)/2)^2 if n-k^2 is even.
Note that k^2 is the largest square which is at most n.
EXAMPLE
For n=6, we have k=floor(sqrt(6))=2; since 6-2=4 is even, a(6)=((6+2)/2)^2=16.
CROSSREFS
KEYWORD
nonn
AUTHOR
Eric Angelini and Benoit Jubin, Nov 23 2009
STATUS
approved