A241898 a(n) is the largest integer such that n = a(n)^2 + ... is a decomposition of n into a sum of at most four nondecreasing squares.
1, 1, 1, 2, 1, 1, 1, 2, 3, 1, 1, 2, 2, 1, 1, 4, 2, 3, 1, 2, 2, 2, 1, 2, 5, 2, 3, 2, 2, 1, 2, 4, 2, 3, 1, 6, 2, 2, 1, 2, 4, 2, 3, 2, 3, 1, 2, 4, 7, 5, 1, 4, 2, 3, 1, 2, 4, 3, 3, 2, 5, 2, 3, 8, 4, 4, 3, 4, 2, 3, 2, 6, 4, 5, 5, 3, 4, 2, 3, 4, 9, 4, 3, 4, 6, 5, 2
Offset: 1
Examples
30 can be written as the sum of at most 4 nondecreasing squares in the following ways: 1^2 + 2^2 + 5^2 or 1^2 + 2^2 + 3^2 + 4^2. Therefore, a(30)=1.
Links
- Alois P. Heinz, Table of n, a(n) for n = 1..10000
Crossrefs
Cf. A191090.
Programs
-
Maple
b:= proc(n, i, t) option remember; n=0 or t>0 and i^2<=n and (b(n, i+1, t) or b(n-i^2, i, t-1)) end: a:= proc(n) local k; for k from isqrt(n) by -1 do if b(n, k, 4) then return k fi od end: seq(a(n), n=1..100); # Alois P. Heinz, May 25 2014
-
Mathematica
For[i=0,i<=7^4,i++,a[i]={}]; For[i1=0,i1<=7,i1++, For[i2=0,i2<=7,i2++, For[i3=0,i3<=7,i3++, For[i4=0,i4<=7,i4++, sumOfSquares=i1^2+i2^2+i3^2+i4^2; smallestSquare=Min[DeleteCases[{i1,i2,i3,i4},0]]; a[sumOfSquares]=Union[{smallestSquare},a[sumOfSquares]] ]]]]; Table[Max[a[i]],{i,1,50}]
Comments