Prime-proof Squbes

We shall define a sqube to be a number of the form, $p^2 q^3$, where $p$ and $q$ are distinct primes.
For example, $200 = 5^2 2^3$ or $120072949 = 23^2 61^3$.
The first five squbes are $72, 108, 200, 392$, and $500$.
Interestingly, $200$ is also the first number for which you cannot change any single digit to make a prime; we shall call such numbers, prime-proof. The next prime-proof sqube which contains the contiguous sub-string “$200$” is $1992008$.
Find the $200$th prime-proof sqube containing the contiguous sub-string “$200$”.

This problem could not be solved accurately without the implementation of a programming language.

But we would start by first specifying what we want to do:
First, we need a function to generate the sqube numbers, that’s relatively straightforward, we generate all combinations of two distinct prime numbers (enumerate all p and q), square the first and cube the second, then multiply them together. We sort all these numbers.

Second, for each of these sqube, we need to check if it is prime-proof. We write a function that checks if a number is a prime. For each digit in the sqube, we replace it with numbers from 0 to 9 and call the is_prime function. If any of these is a prime, then it’s not prime-proof. We maintain a counter of such prime-proof squbes.

Third, for each of the prime-proof sqube we find, we check if it contains the string “200”. If it does, we increment a counter.

Once all these are implemented, we simply iterate through our sorted list of generator squbes, and perform the second and third step until our counter in the third step reaches 200, then we print out that number.

Due to the computational nature of this problem, it is better solved using a language like Python or C++.

Remember, always consider computational efficiency. For example, when checking for primes up to N, it’s better to generate all the primes up to N once instead of check if each number up to N is a prime. Also, once you find a number is not a prime, you don’t need to check the rest digits.

More Answers:
A Recursively Defined Sequence
Ambiguous Numbers
Iterative Circle Packing

Error 403 The request cannot be completed because you have exceeded your quota. : quotaExceeded

Share:

Recent Posts

Don't Miss Out! Sign Up Now!

Sign up now to get started for free!