OFFSET
0,3
COMMENTS
Sum analog of R. L. Graham's sequence (A006255).
LINKS
Peter Kagey, Table of n, a(n) for n = 0..3000
FORMULA
a(n^2) = n^2.
EXAMPLE
a(0) = 0 via 0 = 0^2
a(1) = 1 via 1 = 1^2
a(2) = 4 via 2 + 3 + 4 = 3^2
a(3) = 6 via 3 + 6 = 3^2
a(4) = 4 via 4 = 2^2
a(5) = 10 via 5 + 6 + 7 + 8 + 10 = 6^2
a(6) = 10 via 6 + 10 = 4^2
PROG
(PARI) a(n)=if (issquare(n), return (n)); ok = 0; d = 1; while (!ok, for (j=1, 2^d-1, b = Vecrev(binary(j)); if (issquare(n+sum(k=1, #b, b[k]*(n+k))), ok = 1; break); ); if (! ok, d++); ); n+d; \\ Michel Marcus, Oct 16 2016
(Haskell)
import Data.List (find)
import Data.Maybe (fromJust)
isSquare m = m == (integerRoot * integerRoot) where
integerRoot = floor (sqrt (fromIntegral m)::Double)
a277278 n
| isSquare n = n
| otherwise = last $ fromJust $ find (isSquare . sum) s where
s = map ((n:) . map (n+)) a048793_tabf
-- Peter Kagey, Oct 19 2016
CROSSREFS
KEYWORD
nonn
AUTHOR
Peter Kagey, Oct 15 2016
STATUS
approved