Problem 51241. Compute home primes in a given base

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

30.23% Correct | 69.77% Incorrect
Last Solution submitted on Sep 11, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers10

Suggested Problems

More from this Author281

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!