Pandigital prime: Difference between revisions
Content added Content deleted
(→{{header|Wren}}: Added a 0..n digit version.) |
(→Using digits 0 to n: Sigh, no need to check 3 digit cases in fact.) |
||
Line 531: | Line 531: | ||
</pre> |
</pre> |
||
===Using digits 0 to n=== |
===Using digits 0 to n=== |
||
Applying the Factor logic for the digits 0..n, we only need to check 8 |
Applying the Factor logic for the digits 0..n, we only need to check 8 and 5 digit cases as it can't be any of the others. |
||
<lang ecmascript>import "/math" for Int |
<lang ecmascript>import "/math" for Int |
||
import "/fmt" for Fmt |
import "/fmt" for Fmt |
||
Line 563: | Line 563: | ||
System.print("The largest pandigital decimal prime which uses all the digits 0..n once is:") |
System.print("The largest pandigital decimal prime which uses all the digits 0..n once is:") |
||
for (n in [7, 4 |
for (n in [7, 4]) { |
||
var perms = permutations.call((0..n).toList) |
var perms = permutations.call((0..n).toList) |
||
for (i in perms.count - 1..0) { |
for (i in perms.count - 1..0) { |