How to generalise "Find the biggest 5 digit prime with the sum of digits = 35"?
Matthew Harrington
Part of my assignement was to find the biggest 5 digit prime number with the sum of its digits = 35, since 7+7+7+7+7=35 then the range of possible numbers would be from 77777-99999, for some reson starting from 99999 seemed more safe and after a few tries I've found 99971 to be the desired number. I've thought of either writing a code to filter the numbers and find the desired prime or just to get a list of primes and manually brute force my way in, either method would've taken no more than 10 minutes.
My question: Would it be possible to generalise this type of problem so it would be solvable on paper with little effort (or writing a code to solve in polynomial time for huge primes)? Say for 30 digits primes or more. Just curious.
$\endgroup$ 2 Reset to default