OFFSET
0,6
COMMENTS
Inspired by A034295, but not involving the same geometrical idea & restrictions.
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..10000
FORMULA
a(n^2+1) >= A034295(n).
EXAMPLE
a(16)=7 since 16 = 3^2+7*1 = 3^2+2^2+3*1 = 2^2+12*1 = 2*2^2+8*1 = 3*2^2+4*1 = 4*2^2 = 16*1^2 (where 1 = 1^2).
a(17)=9 since 17 = 4^2+1 = 3^2+8*1 = 3^2+2^2+4*1 = 3^2+2*2^2 = 2^2+13*1 = 2*2^2+9*1 = 3*2^2+5*1 = 4*2^2+1 = 17*1^2.
MAPLE
b:= proc(n, i) option remember; `if`(n=0, 1,
`if`(i<1, 0, b(n, i-1) +`if`(i^2>n, 0, b(n-i^2, i))))
end:
a:= proc(n) local r; r:= isqrt(n);
b(n, r-`if`(r^2>=n, 1, 0))
end:
seq(a(n), n=0..100); # Alois P. Heinz, Apr 16 2013
MATHEMATICA
b[n_, i_] := b[n, i] = If[n == 0, 1,
If[i < 1, 0, b[n, i - 1] + If[i^2 > n, 0, b[n - i^2, i]]]];
a[n_] := With[{r = Floor@Sqrt[n]}, b[n, r - If[r^2 >= n, 1, 0]]];
Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Apr 28 2022, after Alois P. Heinz *)
PROG
(PARI) a(n, m)={!m && n<5 && return(n!=1); m || m=sqrtint(n-1); sum(k=2, m, sum(j=1, n\k^2, a(n-j*k^2, k-1)), 1)}
CROSSREFS
KEYWORD
nonn
AUTHOR
M. F. Hasler, Apr 12 2013
STATUS
approved