문제

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