Problem 44343. Pair Primes
Let's define pair primes as follow;
- 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:
1-) 1637 and 7549 are pair primes. First ends with 7 and second starts with 7.
2-) 6221 and 2113 are pair primes. First ends with 21 and second starts with 21.
3-) 1429 and 4297 are pair primes. First ends with 429 and second starts with 429. You should be careful. 2111 and 1117 are also four digit pair primes. It satisfies three conditions. First ends with 1 and second starts with 1. First ends with 11 and second starts with 11. First ends with 111 and second starts with 111. [2111 1117] pair should be counted for once.
Given the digit counts, can you determine how many unique pair primes are there (a~=b)
Solution Stats
Problem Comments
-
5 Comments
Show
2 older comments
Mehmet OZC
on 24 Oct 2017
Thanks for pointing it out. They are different pair primes.
Rafael S.T. Vieira
on 9 Jul 2020
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.
Brandon
on 29 Jun 2023
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 commentsGroup

2021 New Year Cody Competition
- 30 Problems
- 3 Finishers
- Make a random, non-repeating vector.
- Pizza!
- Triangle Numbers
- Generate a vector like 1,2,2,3,3,3,4,4,4,4
- Find nth maximum
- surrounded matrix
- Calculate the area of a triangle between three points
- Return the first and last characters of a character array
- Smallest distance between a point and a rectangle
- N-Queens Checker
- Minefield Sonar
- Get the length of a given vector
- Select every other element of a vector
- Create a vector
- Convert from Fahrenheit to Celsius
- Set the array elements whose value is 13 to 0
- Remove NaN ?
- Find matching string from a list of strings
- The sliding puzzle: 3D
- Draw 'E'
- Find the maximum number of decimal places in a set of numbers
- calculate the day of the year from a date string.
- Reverse the vector
- Matlab Basics - Convert a row vector to a column vector
- Times 2 - START HERE
- Which coins to give
- Fibonacci sequence
- Find max prime number
- Longest Divisor Run
- Perfect Square or not
Problem Recent Solvers103
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!