Problem 44343. Pair Primes
- For 2 digits numbers: 11 and 17 are pair primes because both of them are 2 digits prime numbers and last digit of the first prime equals to the first digit of second prime number. 11 and 11 are not pair primes because a = b.
- For 3 digit numbers: 389 and 967 are pair primes because both of them are 3 digits prime numbers and last digit of the first prime equals to the first digit of the second prime number (797 and 797 are not pair primes because a = b). 467 and 673 are pair primes too because the last two digits of the first prime number (67) equals to the first two digit (67) of the second prime number. 211 and 113 are pair primes too but they satisfy two conditions: last digit of the first prime equals to the first digit of the second prime also last two digits of the first prime equals to the first two digits of the first prime.
- For 4 digit numbers:
Solution Stats
Problem Comments
-
5 Comments
there are quite a few look-up table solutions, could you perhaps add something like the following to the test suite to discourage these? assert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[51,2485,136162,8578934]),regexp(fileread('pairPrimes.m'),'[\d\.\+\-\*\/]+','match'))))
Do you consider (13, 31) and (31, 13) as the same or different pair primes? Similarly, how about (79, 97) and (97, 79)?
Thanks for pointing it out. They are different pair primes.
Good problem. At first, I thought we needed to reverse the numbers, but only their order is necessary. And we need to count twice numbers like 31 and 13.
Why ban elseif for this problem? I need a test for x==2, x==3, x==4, and x==5. But if one test is true, I do not want the rest to execute. The best way to do this is with elseif.
So I hacked the answer to spite it all.
Solution Comments
Show commentsProblem Recent Solvers103
Suggested Problems
-
4077 Solvers
-
Return the 3n+1 sequence for n
8271 Solvers
-
252 Solvers
-
Get the elements of diagonal and antidiagonal for any m-by-n matrix
476 Solvers
-
355 Solvers
More from this Author92
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!