Hint for Project Euler Problem 41 Pandigital prime
Tags: #Project Euler without coding series #wolfram alpha rocks
Pandigital prime
Problem 41
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime.
What is the largest n-digit pandigital prime that exists?
https://projecteuler.net/problem=41
It is easy to prove that if n-digit number N can be divided by 3, the sum of all its digits can be divided by 3.
Therefore, the pandigital number forms by 123456789 can be divided by 3 (sum of its 9 digits is 45), thus it cannot be a prime number.
Similarly, the pandigital number forms by 12345678 can be divided by 3 (sum of its 9 digits is 45-9 = 36), thus it cannot be a prime number.
The best we can do on this is a 7 digit number forms by 7654321.
Test the number from largest to smallest on www.wolframalpha.com.
7654321
7654213
7654123
7653421
7653241
7652431
7652413 -> bingo!
We got our answer without coding and within only 7 trials.
---------------------
The opinion above is original and unproven work. Please correct me if I made a mistake.
Pandigital prime
Problem 41
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime.
What is the largest n-digit pandigital prime that exists?
https://projecteuler.net/problem=41
It is easy to prove that if n-digit number N can be divided by 3, the sum of all its digits can be divided by 3.
Therefore, the pandigital number forms by 123456789 can be divided by 3 (sum of its 9 digits is 45), thus it cannot be a prime number.
Similarly, the pandigital number forms by 12345678 can be divided by 3 (sum of its 9 digits is 45-9 = 36), thus it cannot be a prime number.
The best we can do on this is a 7 digit number forms by 7654321.
Test the number from largest to smallest on www.wolframalpha.com.
7654321
7654213
7654123
7653421
7653241
7652431
7652413 -> bingo!
We got our answer without coding and within only 7 trials.
---------------------
The opinion above is original and unproven work. Please correct me if I made a mistake.
Comments
Post a Comment