We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
if n < 2 :
return(False)
if n == 2 :
return(True)
if n % 2 == 0 :
return(False)
for i in range(3, int(n**0.5)+1 , 2):
if n % i == 0 :
return(False)
return(True)
def iscircular (n) :
ch=str(n)
l=[]
for i in range(len(ch)) :
rotated_str = ch[i:] + ch[:i]
l.append(int(rotated_str))
for e in l :
if not isprime(e) :
return(False)
return(True)
n=int(input())
d={10:17}
s=17
for i in range(11,10**6 +1):
d[i]=s
if iscircular (i) :
s+=i
print(d[n])
Cookie support is required to access HackerRank
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 →
def isprime(n):
def iscircular (n) :
n=int(input())
d={10:17}
s=17
for i in range(11,10**6 +1):
print(d[n])