A122729 Primes that are the sum of 5 positive cubes.
5, 19, 31, 59, 71, 83, 89, 97, 101, 109, 127, 131, 157, 181, 199, 227, 233, 241, 251, 257, 269, 281, 283, 293, 307, 331, 347, 349, 353, 373, 379, 409, 421, 431, 433, 443, 449, 461, 487, 499, 503, 523, 541, 557, 563, 569, 587, 593, 599, 601, 619, 631, 647, 661
Offset: 1
Examples
a(1) = 5 = 1^3 + 1^3 + 1^3 + 1^3 + 1^3. a(2) = 19 = 1^3 + 1^3 + 1^3 + 2^3 + 2^3. a(3) = 31 = 1^3 + 1^3 + 1^3 + 1^3 + 3^3. a(4) = 59 = 3^3 + 2^3 + 2^3 + 2^3 + 2^3.
Links
- Charles R Greathouse IV, Table of n, a(n) for n = 1..10000
Programs
-
Mathematica
q = 10; lst = {}; Do[Do[Do[Do[Do[p = a^3 + b^3 + c^3 + d^3 + e^3; If[PrimeQ[p], AppendTo[lst, p]], {e, q}], {d, q}], {c, q}], {b, q}], {a, q}]; Take[Union[lst], 80] (* Vladimir Joseph Stephan Orlovsky, Jul 15 2011 *) With[{upto=650},Union[Select[Total/@Tuples[Range[Surd[upto-4,3]]^3,5], PrimeQ[ #]&<=upto&]]] (* Harvey P. Dale, Sep 30 2018 *)
-
PARI
list(lim)=my(ta,tb,tc,td,te,v=List());for(a=1,(lim/5)^(1/3),ta=a^3;for(b=a,((lim-ta)/4)^(1/3),tb=ta+b^3;for(c=b,((lim-tb)/3)^(1/3),tc=tb+c^3;for(d=c,((lim-tc)/2)^(1/3),td=tc+d^3;forstep(e=if(td%2==d%2,d+1,d),(lim-td)^(1/3),2,te=td+e^3;if(ispseudoprime(te),listput(v,te)))))));vecsort(Vec(v),,8) \\ Charles R Greathouse IV, Jul 15 2011
-
Python
from sympy import isprime from collections import Counter from itertools import combinations_with_replacement as combs_w_rep def aupto(lim): s = filter(lambda x: x<=lim, (i**3 for i in range(1, int(lim**(1/3))+2))) s2 = filter(lambda x: x<=lim, (sum(c) for c in combs_w_rep(s, 5))) s2counts = Counter(s2) return sorted(filter(isprime, s2counts)) print(aupto(661)) # Michael S. Branicky, May 19 2021
Comments