from sympy import isprime
def cyclically_rotate_left(n) :
m = n
p = 1
while (m >= 10) :
p *= 10
m /= 10
return int((m + 10 * (n % p)))
def is_circular_prime(n) :
if (not isprime(n)) :
return False
rotated_n = cyclically_rotate_left(n)
while (rotated_n != n) :
if (rotated_n < n or not isprime(rotated_n)) :
return False
rotated_n = cyclically_rotate_left(rotated_n)
return True
print(is_circular_prime(3779))
'''
run:
True
'''