|
|
A006892
|
|
Representation as a sum of squares requires n squares with greedy algorithm.
(Formerly M0860)
|
|
7
|
|
|
1, 2, 3, 7, 23, 167, 7223, 13053767, 42600227803223, 453694852221687377444001767, 51459754733114686962148583993443846186613037940783223
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
COMMENTS
|
Of course Lagrange's theorem tells us that any positive integer can be written as a sum of at most four squares (cf. A004215).
|
|
REFERENCES
|
N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
|
|
LINKS
|
|
|
FORMULA
|
For n >= 4, a(n) = a(n-1) + ((a(n-1)+1)/2)^2. - Joe K. Crump (joecr(AT)carolina.rr.com), Apr 16 2000
|
|
EXAMPLE
|
Here is why a(5) = 23: start with 23, subtract largest square <= 23, which is 16, getting 7.
Now subtract largest square <= 7, which is 4, getting 3.
Now subtract largest square <= 3, which is 1, getting 2.
Now subtract largest square <= 2, which is 1, getting 1.
Now subtract largest square <= 1, which is 1, getting 0.
Thus 23 = 16+4+1+1+1.
It took 5 steps to get to 0, and 23 is the smallest number which takes 5 steps. - N. J. A. Sloane, Jan 29 2014
|
|
PROG
|
(PARI) a(n) = if (n <= 3, n , ((a(n-1)+3)/2)^2 - 2) \\ Michel Marcus, May 25 2013
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|