# Project Euler #35: Circular primes

# Project Euler #35: Circular primes

neverloseks + 2 comments all the prime numbers which contains 0/2/4/6/8/5 can't make a circular prime number because last digit with those number is not the prime number(divisible by 2 or 5) so sieve skill will have a powerful effect on reducing domain again...

bh2smith + 1 comment One issue here is that it is not specified whether a prime which is circluar and \leq N is still defined to be circluar if its rotations happen to exceed N. Perhaps this distinction should be clarified.

shashank21jHackerRank AdminChallenge Author + 0 comments Okay added it if this wasn't clear.

mike006322 + 0 comments Make sure you're testing ROTATIONS of the digits instead of permutations. I made that mistake.

prerakd + 1 comment Can somebody(staff members) please give me a hint why I am getting WA.I think my logic is correct.Is there a problem with exceeding the value of data type?

stomoz + 0 comments I also got it wrong first, note that these are not permutable, but circular primes. http://primes.utm.edu/glossary/xpage/CircularPrime.html

wzrds3 + 0 comments All circular primes less than 10^6 can be found and sorted in under 0.5 seconds using Python 3. Here are some tips.

dareitnot54 + 0 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

SOKS33 + 0 comments You shouldn't run in more than 6s in python without headaches. First compute all primes below N Then for each, play with strings for each rotation and sum primes that are circular.

And voilÃ , all TC cleared

h1606225 + 0 comments test case 5...timeout ??

Premprakash1234 + 0 comments Can sum1 help me in improvise my code.. getting timeout error for testcase 4 and 5..

thanks in advance..

Sort 16 Discussions, By:

Please Login in order to post a comment