We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
If your stuck it may help to know that all pandigital primes are 4 or 7 digit pandigitals.
proof:
if the digits of a number sum to a number divisible by 3, the number is also divisible by 3. It is easily verified that the digits 1 to n sum to a number divisible by 3 for n = 2, 3, 5, 6, 8, and 9, thus all pandigitals with that many digits are divisible by three, and are thus not prime. The only 1 digit pandigital is 1, which is not prime. This leaves only 4 digit and 7 digit pandigitals as candidates.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #41: Pandigital prime
You are viewing a single comment's thread. Return to all comments →
If your stuck it may help to know that all pandigital primes are 4 or 7 digit pandigitals.
proof: if the digits of a number sum to a number divisible by 3, the number is also divisible by 3. It is easily verified that the digits 1 to n sum to a number divisible by 3 for n = 2, 3, 5, 6, 8, and 9, thus all pandigitals with that many digits are divisible by three, and are thus not prime. The only 1 digit pandigital is 1, which is not prime. This leaves only 4 digit and 7 digit pandigitals as candidates.