Minimum primes: Difference between revisions

Content added Content deleted
m (→‎{{header|Ring}}: streamlined)
(Undo revision 345818 by Enter your username (talk))
Line 178: Line 178:


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


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


for n = 1 to len(Numbers1)
? "The maximum prime numbers of three lists = " + fmtArray(Nums)
Temp = []
put "done..."
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


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


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


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