Cody

# Problem 1095. Circular Primes (based on Project Euler, problem 35)

Solution 2793715

Submitted on 5 Aug 2020 by Nadee Seneviratne
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
[y numbers]=circular_prime(197) assert(isequal(y,16)&&isequal(numbers,[2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197]))

what_numbers = 2 what_numbers = 2 3 what_numbers = 2 3 5 what_numbers = 2 3 5 7 what_numbers = 2 3 5 7 11 what_numbers = 2 3 5 7 11 13 what_numbers = 2 3 5 7 11 13 17 what_numbers = 2 3 5 7 11 13 17 31 what_numbers = 2 3 5 7 11 13 17 31 37 what_numbers = 2 3 5 7 11 13 17 31 37 71 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 y = 16 numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197

2   Pass
[y numbers]=circular_prime(100) assert(isequal(y,13)&&isequal(numbers,[2 3 5 7 11 13 17 31 37 71 73 79 97]))

what_numbers = 2 what_numbers = 2 3 what_numbers = 2 3 5 what_numbers = 2 3 5 7 what_numbers = 2 3 5 7 11 what_numbers = 2 3 5 7 11 13 what_numbers = 2 3 5 7 11 13 17 what_numbers = 2 3 5 7 11 13 17 31 what_numbers = 2 3 5 7 11 13 17 31 37 what_numbers = 2 3 5 7 11 13 17 31 37 71 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 y = 13 numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97

3   Pass
[y numbers]=circular_prime(250) assert(isequal(y,17)&&isequal(numbers,[2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199]))

what_numbers = 2 what_numbers = 2 3 what_numbers = 2 3 5 what_numbers = 2 3 5 7 what_numbers = 2 3 5 7 11 what_numbers = 2 3 5 7 11 13 what_numbers = 2 3 5 7 11 13 17 what_numbers = 2 3 5 7 11 13 17 31 what_numbers = 2 3 5 7 11 13 17 31 37 what_numbers = 2 3 5 7 11 13 17 31 37 71 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 y = 17 numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199

4   Pass
[y numbers]=circular_prime(2000) assert(isequal(y,27)&&isequal(numbers,[2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 719 733 919 971 991 1193 1931]))

what_numbers = 2 what_numbers = 2 3 what_numbers = 2 3 5 what_numbers = 2 3 5 7 what_numbers = 2 3 5 7 11 what_numbers = 2 3 5 7 11 13 what_numbers = 2 3 5 7 11 13 17 what_numbers = 2 3 5 7 11 13 17 31 what_numbers = 2 3 5 7 11 13 17 31 37 what_numbers = 2 3 5 7 11 13 17 31 37 71 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 719 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 719 733 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 719 733 919 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 719 733 919 971 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 719 733 919 971 991 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 26 197 199 311 337 373 719 733 919 971 991 1193 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 27 197 199 311 337 373 719 733 919 971 991 1193 1931 y = 27 numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 27 197 199 311 337 373 719 733 919 971 991 1193 1931

5   Pass
[y numbers]=circular_prime(10000) assert(isequal(y,33)&&isequal(numbers,[2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 3779 7793 7937 9311 9377]))

what_numbers = 2 what_numbers = 2 3 what_numbers = 2 3 5 what_numbers = 2 3 5 7 what_numbers = 2 3 5 7 11 what_numbers = 2 3 5 7 11 13 what_numbers = 2 3 5 7 11 13 17 what_numbers = 2 3 5 7 11 13 17 31 what_numbers = 2 3 5 7 11 13 17 31 37 what_numbers = 2 3 5 7 11 13 17 31 37 71 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 719 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 719 733 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 719 733 919 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 719 733 919 971 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 719 733 919 971 991 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 26 197 199 311 337 373 719 733 919 971 991 1193 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 27 197 199 311 337 373 719 733 919 971 991 1193 1931 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 28 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 29 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 3779 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 30 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 3779 7793 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 30 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 3779 7793 Column 31 7937 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 30 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 3779 7793 Columns 31 through 32 7937 9311 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 30 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 3779 7793 Columns 31 through 33 7937 9311 9377 y = 33 numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 30 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 3779 7793 Columns 31 through 33 7937 9311 9377

6   Pass
[y numbers]=circular_prime(54321) assert(isequal(y,38)&&isequal(numbers,[2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 3779 7793 7937 9311 9377 11939 19391 19937 37199 39119]))

what_numbers = 2 what_numbers = 2 3 what_numbers = 2 3 5 what_numbers = 2 3 5 7 what_numbers = 2 3 5 7 11 what_numbers = 2 3 5 7 11 13 what_numbers = 2 3 5 7 11 13 17 what_numbers = 2 3 5 7 11 13 17 31 what_numbers = 2 3 5 7 11 13 17 31 37 what_numbers = 2 3 5 7 11 13 17 31 37 71 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 719 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 719 733 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 719 733 919 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 719 733 919 971 what_numbers = 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 197 199 311 337 373 719 733 919 971 991 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 26 197 199 311 337 373 719 733 919 971 991 1193 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 27 197 199 311 337 373 719 733 919 971 991 1193 1931 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 28 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 29 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 3779 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 30 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 3779 7793 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 30 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 3779 7793 Column 31 7937 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 30 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 3779 7793 Columns 31 through 32 7937 9311 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 30 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 3779 7793 Columns 31 through 33 7937 9311 9377 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 30 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 3779 7793 Columns 31 through 34 7937 9311 9377 11939 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 30 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 3779 7793 Columns 31 through 35 7937 9311 9377 11939 19391 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 30 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 3779 7793 Columns 31 through 36 7937 9311 9377 11939 19391 19937 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 30 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 3779 7793 Columns 31 through 37 7937 9311 9377 11939 19391 19937 37199 what_numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 30 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 3779 7793 Columns 31 through 38 7937 9311 9377 11939 19391 19937 37199 39119 y = 38 numbers = Columns 1 through 15 2 3 5 7 11 13 17 31 37 71 73 79 97 113 131 Columns 16 through 30 197 199 311 337 373 719 733 919 971 991 1193 1931 3119 3779 7793 Columns 31 through 38 7937 9311 9377 11939 19391 19937 37199 39119