Minimum primes: Difference between revisions
Content added Content deleted
(Minimum primes en FreeBASIC) |
|||
Line 190: | Line 190: | ||
{ 43 101 79 59 67 } |
{ 43 101 79 59 67 } |
||
</pre> |
</pre> |
||
=={{header|FreeBASIC}}== |
|||
<lang freebasic>#define MAX(a, b) iif((a) > (b), (a), (b)) |
|||
Function isPrime(Byval ValorEval As Integer) As Boolean |
|||
If ValorEval < 2 Then Return False |
|||
If ValorEval Mod 2 = 0 Then Return ValorEval = 2 |
|||
If ValorEval Mod 3 = 0 Then Return ValorEval = 3 |
|||
Dim d As Integer = 5 |
|||
While d * d <= ValorEval |
|||
If ValorEval Mod d = 0 Then Return False Else d += 2 |
|||
Wend |
|||
Return True |
|||
End Function |
|||
Dim As Integer Num1(5) = { 5,45,23,21,67} |
|||
Dim As Integer Num2(5) = {43,22,78,46,38} |
|||
Dim As Integer Num3(5) = { 9,98,12,54,53} |
|||
Print "The minimum prime numbers of three lists..." |
|||
Print "["; |
|||
For n As Integer = 0 To 4 |
|||
Dim As Integer maxi = MAX(num1(n), MAX(num2(n), num3(n))) |
|||
If (maxi Mod 2 = 0) Then maxi += 1 |
|||
While Not isPrime(maxi) |
|||
maxi += 2 |
|||
Wend |
|||
Print maxi; ", "; |
|||
Next n |
|||
Print !"\b\b ]" |
|||
Sleep</lang> |
|||
{{out}} |
|||
<pre> |
|||
[ 43, 101, 79, 59, 67 ] |
|||
</pre> |
|||
=={{header|Go}}== |
=={{header|Go}}== |