A 10-digit number with all the different decimal digits will be divisible by 3 as the sum of the digits would be 45, which is divisible by 3. A non-zero digit must be eliminated, so a prime with 9 digits will need to have a zero.
5 P=98700000
10 while P<99000000
30 P=fnNxprime(P)
40 Ps=cutspc(str(P))
50 Good=1
60 for I=1 to len(Ps)-1
70 if instr(mid(Ps,I+1,*),mid(Ps,I,1))>0 then Good=0:cancel for:goto 100
80 next
90 if Good then print P
100 wend
999 end
The last few 9-digit cases are:
987651403
987652301
987653201
987654103
so 987654103 is the highest when zero is included.
The last few 8-digit cases are:
98764321
98765143
98765201
98765413
98765431
which includes the highest without a zero: 98765431.
|
Posted by Charlie
on 2013-09-18 17:33:46 |