The program below is meant to find all of the fare prime numbers under a user specified value. A fare prime being a number that when its digits are rotated, each combination makes a prime number. An example being 113 because 113, 311, and 131 are all prime numbers. My current problem is that the program takes a very long time to process very large numbers so I need a way of making it run quicker. I've tried to explain the code with the comments but if any part doesn't make sense I'll do my best to explain.
#get user input for the number range
n = int(input("number"))
primes = []
#find all the prime numbers up to the specified value and append them to a list
for num in range(2, n+1):
for i in range(2, num):
if num % i == 0:
break
else:
primes.append(num)
#find out if the prime number is a fare prime
for i in primes:
length = len(str(i))
#if the number has one digit it is automatically a fare prime
if length == 1:
print(i)
#if the number is longer, rotate the digits to see if it is a fare prime
if length >= 2:
number = i
fare_primes = []
#rotate the number to figure out if all combinations are prime
for j in range(length):
#turns # into a list of digits
digit_list = list(str(number))
#rearranges
number = [*digit_list[1::], digit_list[0]]
part = ""
#turns it back into an int value
number = part.join(number)
int_num = int(number)
#check if # is prime
for divider in range(2,int_num):
if int_num % divider == 0:
break
else:
fare_primes.append(number)
#if all combinations of the digits are prime the original # is printed
if len(fare_primes) == length:
print(fare_primes[-1])