A home prime for a particular number is determined by factoring the number, concatenating the factors of the number (written in increasing order), and stopping when the resulting number is prime. The number 35149 is the home prime of 60 in base 10
2, 2, 3, 5 --> 2235 --> 35, 149 --> 35149
For a different base b, write the factors of the base-10 number in base b, concatenate the factors, and convert the result from base b to base 10. For example, the home prime of 60 in base 4 is 32183:
Factors in base 10 Factors in base 4 Base 4 number Base 10 number
2, 2, 3, 5 2, 2, 3, 11 22311 693
3, 3, 7, 11 3, 3, 13, 23 331323 3963
3, 1321 3, 110221 3110221 13609
31, 439 133, 1231 1331231 32183
Write a function that computes the home prime in the specified base. If the base is not specified, take it to be 10. If your code can pass the four optional tests (removed with comments in the test suite), please leave a note in the comments.
Solution Stats
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers11
Suggested Problems
-
Smallest distance between a point and a rectangle
275 Solvers
-
10620 Solvers
-
510 Solvers
-
7961 Solvers
-
444 Solvers
More from this Author321
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
You could do those additional tests if the output were a character array by using Java BigInteger or Python.
Please correct that base 1 on your multiple bases case to 10