Pandigital prime: Difference between revisions

→‎{{header|Ring}}: streamlined, added optional task
(→‎{{header|Raku}}: updated for optional task)
(→‎{{header|Ring}}: streamlined, added optional task)
Line 510:
 
=={{header|Ring}}==
<lang ring>see "working..." + nl
for nz = limit1 to 20 step -21
load "stdlib.ring"
see "The largest " + z + "..7 pandigital prime is:" + nl"
see "working..." + nl
limit hi = 7654321
see "The largest pandigital prime is:" + nl
flagif z = 10
 
hi = ok76543201
pand = 0
limit = 7654321
 
for n = limit to 2 step -2
flag = 1
strn = string(n)
if isprime(n)
for m = 1 to len(strn)
ind = count(strn,string(m))
if ind != 1
flag = 0
ok
next
if flag = 1
pand = n
exit
ok
ok
for n = hi to 0 step -18
strn = string(n)
pandig = true
for mi = 1z to len(strn)7
ind =if countsubstr(strn, string(mi)) = 0
pandig = false
flag = 0exit
if ind != 1ok
next
if pandig and isprime(n)
ok see "" + n + nl
pand = nexit
exitok
next
next
see "done..." + nl
 
iffunc isprime(n)
see "" + pand + nl
if n % 3 = 0
 
return false
see "done..." + nl
ok
 
i = 5
func count(cString,dString)
while sumi =* 0i < n
if flagn % i = 10
while substr(cString,dString) > 0
sum++ return false
ok
cString = substr(cString,substr(cString,dString)+len(string(sum)))
end i += 2
return sumend
return true</lang>
{{out}}
<pre>
see "working..." + nl
The largest 1..7 pandigital prime is: 7652413
7,652,413
The largest 0..7 pandigital prime is 76540231
done...
</pre>