Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

How to generalise "Find the biggest 5 digit prime with the sum of digits = 35"?

Writer Matthew Harrington
$\begingroup$

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

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy