Do not make permutations. Make rotations. Only rotate the digits. They have to stay in their order, you can't swap two.
Therefore, the rotations of 197
are 197
, 971
and 719
. Nothing else.
Question
http://projecteuler.net/problem=35
The problem says that the number 197 is a circular prime since all rotations of its digits are prime.
Well as per my understanding all rotations of 197
are 197, 971, 719, 179, 917, 791
and out of which 917
and 791
are not prime.
Then how is 197 a circular prime? Why only 3 of the rotations are considered and the rest 3 are left out? Am I missing something here?
Thanks!!
Solution
Do not make permutations. Make rotations. Only rotate the digits. They have to stay in their order, you can't swap two.
Therefore, the rotations of 197
are 197
, 971
and 719
. Nothing else.
OTHER TIPS
You have listed permutations of 197. Rotations are achieved by shifting, so the only rotations of 197 are 719 and 971