You are viewing a single comment's thread. Return to all comments →
Here is my code passed 7/7:
import sys sieve=[True]*(10**6+1) sieve[0]=sieve[1]=False for i in range(2,int((10**6)**0.5)+1): if sieve[i]: for m in range(i*i,10**6+1,i): sieve[m]=False primes=[i for i in range(10**6+1) if sieve[i]] sums=dict() s=0 for i in range(1, 10**6+1): if sieve[i]: s+=i sums[i]=s t = int(input().strip()) for a0 in range(t): n = int(input().strip()) while n>1: if n in sums: print(sums[n]) break n-=1
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #10: Summation of primes
You are viewing a single comment's thread. Return to all comments →
Here is my code passed 7/7: