You are viewing a single comment's thread. Return to all comments →
can anyone help me..its showing timeout for last case ..
n=int(raw_input()) def primes(n): if n==2: return [2] elif n<2: return [] s=range(3,n+1,2) mroot = n ** 0.5 half=(n+1)/2-1 i=0 m=3 while m <= mroot: if s[i]: j=(m*m-3)/2 s[j]=0 while j<half: s[j]=0 j+=m i=i+1 m=2*i+3 return [2]+[x for x in s if x] c=primes(322000) ans=0 for z in c: if z<n: count=0 l=str(z) k=len(l) for i in range(1,k+1): new=l[i:k]+l[:i] if int(new) not in c: count=1 break if count==0: ans+=z else: break print ans
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #35: Circular primes
You are viewing a single comment's thread. Return to all comments →
can anyone help me..its showing timeout for last case ..