原题:
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?
分析:
因为一个整数的各个位上的数字之和如果能被3整除,那么该数就能被3整除
所以在所有的pandigital数,只有4位的(1、2、3、4)和7位 的(1、2、3、4、5、6、7)的数字可能为质数。
直接写了一下7位数的。
代码入下: