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?
from tools import is_prime
from itertools import permutations
def run():
primes = []
for item in permutations('1234567'):
candidate = int(''.join(item))
if is_prime(candidate):
primes.append(candidate)
return max(primes)