# Project Euler 41 Generating Pandigital Numbers [closed]

Project Euler question 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?

I have the functions for checking primality, however, instead of going through all numbers up till 987654321, I decided to write a function which generates all the pandigital numbers through recursion.

def make_pan(curr):
global pandigital_numbers
if len(curr) < 9:
for i in range(1, 10):
if str(i) in curr:
continue
else:
make_pan(curr + str(i))
else:
pandigital_numbers.append(int(curr))


There is a list which holds all of the generated pandigital numbers (pandigital_numbers). For some reason, my program is outputting that there is no prime pandigital number in the list. Is there something that my make_pan function is doing to generate all the numbers?

P.S. The initial function call is make_pan("") to start the recursive process

## closed as off-topic by Graipher, Stephen Rauch, yuri, Sᴀᴍ Onᴇᴌᴀ, hjpotter92Aug 13 at 21:01

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Graipher, Stephen Rauch, yuri, Sᴀᴍ Onᴇᴌᴀ, hjpotter92
If this question can be reworded to fit the rules in the help center, please edit the question.

• Just to be sure: the current code does not produce the correct output? – Mast Aug 10 at 6:05
• digits 1 to 9 sum up to 45 thus always divisible by 3 – stefan Aug 10 at 6:24

This got me thinking that if n is equals to the number of digits in a number, then you can have a pandigital number of n = 4 or something which would consist of numbers like 1234 (although it isn't prime)
• By the same logic, it should be noted that $\sum_{i=1}^8 i = 36 \equiv_3 0$, which means that the number will have at most 7 digits. – maxb Aug 10 at 12:10