Sunday March 29, 2009
Circular primes are special primes that hold certain properties...
The number 197 is called a circular prime because all rotations of its digits (197, 971, and 719) are themselves prime.

There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97.

How many circular primes are there below one million?

There are two smaller problems within this larger one. The first is determining whether a number is prime. This is relatively straightforward, but the Wikipedia page on primality tests is a good reference for different methods.

The second problem is finding different permutations of digits. The STL algorithm library provides a method for finding permutations within an array, but an implementation on one data item would be easier to use in finding the solution.

(This problem came from Project Euler's site).
Show solution
©1994-2020   |   Shodor   |   Privacy Policy   |   NSDL   |   XSEDE   |   Blue Waters   |   ACM SIGHPC   |   feedback  |   facebook   |   twitter   |   rss   |   youtube   |   XSEDE Code of Conduct   |   Not Logged In. Login