0%

Problem 87


Problem 87


Prime Power Triples

The smallest number expressible as the sum of a prime square, prime cube, and prime fourth power is 28. In fact, there are exactly four numbers below fifty that can be expressed in such a way:

28=22+23+2433=32+23+2449=52+23+2447=22+33+24

How many numbers below fifty million can be expressed as the sum of a prime square, prime cube, and prime fourth power?


素数幂三元组

最小的、可以表示为一个素数的平方、一个素数的立方和一个素数的四次方之和的数是28。实际上,在小于50的数中,一共有4个数满足这一性质:

28=22+23+2433=32+23+2449=52+23+2447=22+33+24

在小于五千万的数中,有多少个数满足上述性质?


1 comment
Anonymous
Markdown is supported
@shangkelingxiang
shangkelingxiangcommentedabout 3 years ago
pri=[]
v=[0]*100000
v[0]=v[1]=1
for i in range(2,100000):
    if not v[i]:
        pri.append(i)
    for j in pri:
        if i*j>=100000:
            break
        v[i*j]=1
        if i%j==0:
            break
ok=[0]*50000000
a=0
while pri[a]**2<50000000:
    b=0
    while pri[b]**3<50000000-pri[a]**2:
        c=0
        while pri[c]**4<50000000-pri[a]**2-pri[b]**3:
            ok[pri[a]**2+pri[b]**3+pri[c]**4]=1
            c+=1
        b+=1
    a+=1
print(sum(ok))