What is the largest existing n-digit pandigital (i.e.using all digits from 1 to n) prime number ?
100 for N=2 to 9
120 V$=left("123456789",N):H$=V$
200 Max=0
215 repeat
220 gosub *Permute(&V$)
230 P=val(V$)
240 if prmdiv(P)=P then if P>Max then Max=P
250 until V$=H$
260 if Max>0 then print Max
300 next N
800 end
finds
4231
7652413
So only n=4 and n=7 work and these are the only two solutions.
Of course if "largest" means the "largest for all values of n", rather than "for each value of n", then of course 7,652,413 is it.
|
Posted by Charlie
on 2012-09-01 13:35:26 |