Pandigital prime: Difference between revisions
Added Quackery.
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
(Added Quackery.) |
||
Line 530:
Largest decimal pandigital0 prime with 8 digits:76,540,231
</pre>
=={{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. As <code>nextperm</code> generates permutations in lexicographical order the word <code>->revnum</code> subtracts each digit from 8 to give reverse lexicographical order.
<code>nextperm</code> is defined at [[Permutations with some identical elements#Quackery]].
<code>isprime</code> is defined at [[Primality by trial division#Quackery]].
<syntaxhighlight lang="Quackery"> [ 0 swap
witheach
[ 8 swap -
swap 10 * + ] ] is ->revnum ( [ --> n )
' [ 1 2 3 4 5 6 7 ]
[ dup ->revnum
isprime not while
nextperm again ]
->revnum
echo</syntaxhighlight>
{{out}}
<pre>7652413</pre>
=={{header|Raku}}==
|