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!!

有帮助吗?

解决方案

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.

其他提示

You have listed permutations of 197. Rotations are achieved by shifting, so the only rotations of 197 are 719 and 971

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top