Anti-primes: Difference between revisions
→{{header|Yabasic}}
Line 1,602:
7560
</pre>
=={{header|Visual Basic .NET}}==
{{trans|D}}
<lang vbnet>Module Module1
Function CountDivisors(n As Integer) As Integer
If n < 2 Then
Return 1
End If
Dim count = 2 '1 and n
For i = 2 To n \ 2
If n Mod i = 0 Then
count += 1
End If
Next
Return count
End Function
Sub Main()
Dim maxDiv, count As Integer
Console.WriteLine("The first 20 anti-primes are:")
Dim n = 1
While count < 20
Dim d = CountDivisors(n)
If d > maxDiv Then
Console.Write("{0} ", n)
maxDiv = d
count += 1
End If
n += 1
End While
Console.WriteLine()
End Sub
End Module</lang>
{{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|Yabasic}}==
|