Minimum primes: Difference between revisions

m
(copyedit)
m (→‎{{header|Ring}}: streamlined)
Line 178:
 
=={{header|Ring}}==
<lang ring>? "working..."
load "stdlib.ring"
see "working..." + nl
 
Num1 = [ 5,45,23,21,67]
Primes = []
Numbers1Num2 = [543,4522,2378,2146,6738]
Numbers2Num3 = [43 9,2298,7812,4654,3853]
n = len(Num1)
Numbers3 = [9,98,12,54,53]
Nums = list(n)
 
for n = 1 to len(Numbers1)
for i = 1 Temp =to []n
Nums[i] = nxtPrime(max([Num1[i], Num2[i], Num3[i]]))
add(Temp,Numbers1[n])
add(Temp,Numbers2[n])
add(Temp,Numbers3[n])
max = max(Temp)
max--
while true
max++
if isprime(max)
exit
ok
end
add(Primes,max)
next
 
? "The minimum prime numbers of three lists = " + fmtArray(Nums)
see "Minimum primes = "
see nl +put "done..." + nl
see showArray(Primes)
 
see nl + "done..." + nl
func fmtArray(ar)
rv = ar[1]
for n = 2 to len(ar) rv += "," + ar[n] next
return txt"[" =+ txtrv + "]"
 
func showArraynxtPrime(arrayx)
iscomp txt= true j = ""2
while see "["iscomp
for n if x % j = 10 j = to2 len(array)x++
else txt = txt j+ array[n] + ","ok
if j * j > x ispr = false exit ok
next
end return string(x)</lang>
txt = left(txt,len(txt)-1)
txt = txt + "]"
see txt
</lang>
{{out}}
<pre>
working...
MinimumThe primesminimum prime numbers of three lists = [43,101,79,59,67]
done...
</pre>