Pandigital prime: Difference between revisions

m
→‎{{header|Quackery}}: added optional pandigital0
m (→‎{{header|Quackery}}: tweaked commentary)
m (→‎{{header|Quackery}}: added optional pandigital0)
Line 533:
=={{header|Quackery}}==
 
As per the Factor solution, only 4 and 7 digit pandigital numbers can be prime. Clearly the largest will have 7 digits. We start with the largest 7 digit pandigital number and work down until we find one that is prime. (If there had been no 7 digit pandigital primes, I would then have added code for a 4 digit solution.) As <code>nextperm</code> generates permutations in lexicographical order the word <code>->revnum</code> subtracts each digit from 8 to give reverse numerical order.
 
<code>nextperm</code> is defined at [[Permutations with some identical elements#Quackery]].
Line 544:
swap 10 * + ] ] is ->revnum ( [ --> n )
 
' [ [ 1 2 3 4 5 6 7 ]
[ 1 2 3 4 5 6 7 8 ] ]
[ dup ->revnum
witheach
isprime not while
[ [ dup ->revnum
nextperm again ]
isprime not while
->revnum
nextperm again ]
echo</syntaxhighlight>
->revnum
echo cr ]</syntaxhighlight>
 
{{out}}
 
<pre>7652413</pre>
76540231
</pre>
 
=={{header|Raku}}==
1,462

edits