Problem 1095. Circular Primes (based on Project Euler, problem 35)
The number, 197, is called a circular prime because all rotations of the 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.
Given a number x, write a MATLAB script that will tell you the number of circular primes less than or equal to x as well as a sorted list of what the circular prime numbers are.
Solution Stats
Problem Comments
-
6 Comments
197 is not circular prime, because neither 791 nor 917 are themselves prime. Only test case 2 is correct.
Christopher, if our number is represented as ABC, then a cicrular prime is a number where ABC, BCA, and CAB are all prime. You are either shifting the numbers in the opposite direction or scrambling them. Not every permutation of the numbers has to be a prime number, although that in itself would be an interesting Cody problem. :-)
good question! tricky
Solution Comments
Show commentsGroup

Computer Games III
- 13 Problems
- 2 Finishers
- I've got the power! (Inspired by Project Euler problem 29)
- Pandigital number n°1 (Inspired by Project Euler 32)
- Pandigital number n°2 (Inspired by Project Euler 32)
- Pandigital number n°3 (Inspired by Project Euler 32)
- Circular Primes (based on Project Euler, problem 35)
- Right Triangle Side Lengths (Inspired by Project Euler Problem 39)
- Lychrel Number Test (Inspired by Project Euler Problem 55)
- Decrypt the cypher using XOR encryption (for beginners)
- Diophantine Equations (Inspired by Project Euler, problem 66)
- High Precision Square Root (Inspired by Project Euler 80)
- Square Digits Number Chain Terminal Value (Inspired by Project Euler Problem 92)
Problem Recent Solvers569
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!