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 = [] |
|||
Num2 = [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) |
|||
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) |
|||
⚫ | |||
ok |
|||
end |
|||
add(Primes,max) |
|||
next |
next |
||
? "The maximum prime numbers of three lists = " + fmtArray(Nums) |
|||
see "Minimum primes = " |
|||
⚫ | |||
see showArray(Primes) |
|||
see nl + "done..." + nl |
|||
func fmtArray(ar) |
|||
rv = ar[1] |
|||
for n = 2 to len(ar) rv += "," + ar[n] next |
|||
⚫ | |||
func |
func nxtPrime(x) |
||
iscomp = true j = 2 |
|||
while iscomp |
|||
if x % j = 0 j = 2 x++ |
|||
else j++ ok |
|||
⚫ | |||
next |
|||
end return string(x)</pre> |
|||
txt = left(txt,len(txt)-1) |
|||
⚫ | |||
see txt |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
working... |
|||
Minimum primes = [43,101,79,59,67] |
|||
⚫ | |||
</pre> |
|||
=={{header|Wren}}== |
=={{header|Wren}}== |