%I #10 Nov 29 2023 06:56:22
%S 0,1,2,2,2,3,4,4,4,4,5,6,6,6,7,8,8,9,10,10,10,11,12,12,12,12,13,14,14,
%T 14,15,16,16,16,16,17,18,19,20,20,20,21,22,22,22,22,23,24,24,24,25,26,
%U 26,26,27,28,28,28,28,29,30,30,30,31,32,33,34,34,34,35,36,36,36,36,37
%N Number of values k < n for which k is a greedy sum of squares.
%H H. L Montgomery and U. M. A. Vorhauer, <a href="http://dx.doi.org/10.1090/S0025-5718-03-01513-8">Greedy sums of distinct squares</a>, Math. Comp. 73 (2004) 493-513, Table 1. [<a href="http://www.ams.org/mathscinet-getitem?mr=2034134">MR2034134</a>].
%p greeds := proc(n) local arem,a,j ; arem := n ; a := [] ; while arem > 0 do j := floor(sqrt(arem)) ; a := [op(a),j] ; arem := arem-j^2 ; od: a ; end: isGreedS := proc(n) option remember; local L; L := greeds(n) ; RETURN( nops(L) = nops( convert(L,set)) ) ; end: a := proc(n) local resul,i ; resul := 0 ; for i from 0 to n-1 do if isGreedS(i) then resul := resul+1 ; fi; od: resul ; end: seq(a(n),n=0..80) ;
%t greeds[n_] := Module[{arem = n, a = {}, j}, While[arem > 0, j = Floor[Sqrt[arem]]; AppendTo[a, j]; arem = arem - j^2]; a];
%t isGreedS[n_] := isGreedS[n] = Module[{L = greeds[n]}, Length[L] == Length[Union[L]]];
%t a[n_] := Module[{resul = 0, i}, For[i = 0, i <= n-1, i++, If[isGreedS[i], resul++]]; resul];
%t Table[a[n], {n, 0, 80}] (* _Jean-François Alcover_, Nov 29 2023, after _R. J. Mathar_ *)
%K easy,nonn
%O 0,3
%A _R. J. Mathar_, Mar 01 2009
|