Project Euler #41: Pandigital prime

  • + 0 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.