login
Numbers that are the sum of at most 4 positive 5th powers.
1

%I #18 Nov 16 2020 09:33:22

%S 0,1,2,3,4,32,33,34,35,64,65,66,96,97,128,243,244,245,246,275,276,277,

%T 307,308,339,486,487,488,518,519,550,729,730,761,972,1024,1025,1026,

%U 1027,1056,1057,1058,1088,1089,1120,1267,1268,1269,1299,1300,1331,1510,1511

%N Numbers that are the sum of at most 4 positive 5th powers.

%H Alois P. Heinz, <a href="/A004844/b004844.txt">Table of n, a(n) for n = 1..10000</a>

%p b:= proc(n, i, t) option remember; n=0 or i>0 and t>0

%p and (b(n, i-1, t) or i^5<=n and b(n-i^5, i, t-1))

%p end:

%p a:= proc(n) option remember; local k;

%p for k from 1+ `if`(n=1, -1, a(n-1))

%p while not b(k, iroot(k, 5), 4) do od; k

%p end:

%p seq(a(n), n=1..50); # _Alois P. Heinz_, Sep 16 2016

%t b[n_, i_, t_] := b[n, i, t] = n==0 || i>0 && t>0 && (b[n, i-1, t] || i^5 <= n && b[n - i^5, i, t-1]);

%t a[n_] := a[n] = Module[{k}, For[k = 1+If[n==1, -1, a[n-1]], !b[k, Floor[ k^(1/5)], 4], k++]; k];

%t Array[a, 50] (* _Jean-François Alcover_, Nov 16 2020, after _Alois P. Heinz_ *)

%K nonn

%O 1,3

%A _N. J. A. Sloane_