Problem 52313. Truncatable Primes
A truncatable prime is a leading digit is successively removed, then all resulting numbers are prime.
When given a number, Return as per the precedence given
1) 0 - if a number is not a prime or not a truncatable prime.
2) 5 - if a number is left-and-right-truncatable prime. E.g. - 127 => 2
3) 9 - if a number is left as well as right truncatable prime but not a left-and-right-truncatable prime.
For e.g - 313 => 13 (left) & 31 (right) but not 1 (left-and-right both)
4) 3 - if a number is (exclusive) left-truncatable prime. E.g - 17 => 7
7 - if a number is (exclusive) right-truncatable prime. E.g. - 29 => 2
Note - String functions are not allowed!
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers5
Suggested Problems
-
Smallest distance between a point and a rectangle
177 Solvers
-
Create a vector whose elements depend on the previous element
644 Solvers
-
763 Solvers
-
Replace multiples of 5 with NaN
437 Solvers
-
How long do each of the stages of the rocket take to burn?
272 Solvers
More from this Author31
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!