OFFSET
0,3
LINKS
Scott R. Shannon, Image for the first 50000 terms.
EXAMPLE
a(1) = 1 as |1 - a(0)| = |1 - 1| = 0, and 0 + 1 = 1 = 1^2 is the next smallest square.
a(2) = 3 as |2 - a(1)| = |2 - 1| = 1, and 1 + 3 = 4 = 2^2 is the next smallest square.
a(5) = 5 as |5 - a(4)| = |5 - 1| = 4, and 4 + 5 = 9 = 3^2 is the next smallest square.
MATHEMATICA
nxt[{n_, a_}]:={n+1, Module[{k=1}, While[!IntegerQ[Sqrt[(Abs[n+1-a])+k]], k++]; k]}; NestList[ nxt, {0, 1}, 90][[;; , 2]] (* Harvey P. Dale, Aug 20 2024 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Scott R. Shannon, Nov 09 2021
STATUS
approved