Minimum primes: Difference between revisions
Content added Content deleted
Line 210: | Line 210: | ||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
===Solution #1=== |
|||
<lang ring>? "working..." |
<lang ring>? "working..." |
||
Line 241: | Line 242: | ||
working... |
working... |
||
The minimum prime numbers of three lists = [43,101,79,59,67] |
The minimum prime numbers of three lists = [43,101,79,59,67] |
||
done... |
|||
</pre> |
|||
===Solution #2=== |
|||
<lang ring> |
|||
load "stdlib.ring" |
|||
see "working..." + nl |
|||
Primes = [] |
|||
Numbers1 = [5,45,23,21,67] |
|||
Numbers2 = [43,22,78,46,38] |
|||
Numbers3 = [9,98,12,54,53] |
|||
for n = 1 to len(Numbers1) |
|||
Temp = [] |
|||
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 = " |
|||
see showArray(Primes) |
|||
see nl + "done..." + nl |
|||
func showArray(array) |
|||
txt = "" |
|||
see "[" |
|||
for n = 1 to len(array) |
|||
txt = txt + array[n] + "," |
|||
next |
|||
txt = left(txt,len(txt)-1) |
|||
txt = txt + "]" |
|||
see txt |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
working... |
|||
Minimum primes = [43,101,79,59,67] |
|||
done... |
done... |
||
</pre> |
</pre> |