Beispiel #1
0
'''
Created on 2011-8-7

@author: huangkan
'''
limit=50*10**6
flag=[False]*(limit+1)
import Mytools
ps=Mytools.primes(int(limit**.5)+1)
for i in ps:
    sum=i*i
    for j in ps:
        sum=i*i+j*j*j
        if sum>limit:
            break
        else:
            for k in ps:
                sum=i**2+j**3+k**4
                if sum>limit:break
                else: flag[sum]=True
ans=0
for i in flag:
    if i:ans+=1
print(ans)
Beispiel #2
0
"""
Created on 2011-7-30

@author: huangkan
"""
import Mytools

limit = 100
l = [0] * (limit + 1)
for i in range(0, limit + 1):
    if i % 2 == 0:
        l[i] = 1
p = Mytools.primes(limit)
for i in p[1:]:
    tl = l[:]
    for j in range(1, int(limit / i) + 1):
        for k in range(limit + 1):
            if k + i * j < limit:
                l[k + i * j] += tl[k]
            else:
                break
print(l)
for i in range(limit):
    if l[i] > 5000:
        print(i)
        break