Project Euler 35 - Circular Primes

Official link: https://projecteuler.net/problem=35

Thought Process

I created a function number_rotation(x) which takes a number x are creates all the rotations by looping through the length of the string, i, and appending str(x)[i:] + str(x)[:i] to a list

As an example lets use 197, len(str(197)) = 3

  1. i = 0 => str(x)[0:] + str(x)[:0] = "197" + ""

  2. i = 1 => str(x)[1:] + str(x)[:1] = "97" + "1"

  3. i = 2 => str(x)[2:] + str(x)[:2] = "7" + "19"

Using my prime generation function I find the first 1,000,000 primes and I loop through this list, create the rotations and check if every element of the list is a prime using my is_prime function

Interactive Code

Input an integer (yourinput)

Code will output the number of Circular primes < yourinput