Minimum primes: Difference between revisions

Content added Content deleted
m (→‎{{header|Ring}}: streamlined)
Line 178: Line 178:


=={{header|Ring}}==
=={{header|Ring}}==
<lang ring>
<lang ring>? "working..."
load "stdlib.ring"
see "working..." + nl


Num1 = [ 5,45,23,21,67]
Primes = []
Numbers1 = [5,45,23,21,67]
Num2 = [43,22,78,46,38]
Numbers2 = [43,22,78,46,38]
Num3 = [ 9,98,12,54,53]
n = len(Num1)
Numbers3 = [9,98,12,54,53]
Nums = list(n)

for n = 1 to len(Numbers1)
Temp = []
for i = 1 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
next


? "The maximum prime numbers of three lists = " + fmtArray(Nums)
see "Minimum primes = "
put "done..."
see showArray(Primes)

see nl + "done..." + nl
func fmtArray(ar)
rv = ar[1]
for n = 2 to len(ar) rv += "," + ar[n] next
return "[" + rv + "]"


func showArray(array)
func nxtPrime(x)
txt = ""
iscomp = true j = 2
see "["
while iscomp
for n = 1 to len(array)
if x % j = 0 j = 2 x++
txt = txt + array[n] + ","
else j++ ok
if j * j > x ispr = false exit ok
next
end return string(x)</pre>
txt = left(txt,len(txt)-1)
txt = txt + "]"
see txt
</lang>
{{out}}
<pre>
working...
Minimum primes = [43,101,79,59,67]
done...
</pre>


=={{header|Wren}}==
=={{header|Wren}}==