Anti-primes: Difference between revisions

Anti-primes in Gambas
(Anti-primes in QBasic)
(Anti-primes in Gambas)
Line 621:
=={{header|BASIC}}==
==={{header|BASIC256}}===
<syntaxhighlight lang="basic256vbnet">
Dim Results(20)
Candidate = 1
Line 693:
1 2 4 6 12 24 36 48 60 120 180 240 360 720 840 1260 1680 2520 5040 7560
</pre>
 
==={{header|Gambas}}===
<syntaxhighlight lang="gambas">Function count_divisors(n As Integer) As Integer
 
Dim i, count As Integer
If n < 2 Then Return 1
count = 2
For i = 2 To n / 2
If Not (n Mod i) Then Inc count
Next
Return count
 
End Function
 
Public Sub Main()
 
Dim count, max_divisors, n, d As Integer
Print "Los primeros 20 anti-primos son:"
While (count < 20)
Inc n
d = count_divisors(n)
If d > max_divisors Then
Print n; " ";
max_divisors = d
Inc count
End If
Wend
End</syntaxhighlight>
{{out}}
<pre>The first 20 anti-primes are:
1 2 4 6 12 24 36 48 60 120 180 240 360 720 840 1260 1680 2520 5040 7560 </pre>
 
==={{header|GW-BASIC}}===
2,139

edits