Anti-primes: Difference between revisions
Content deleted Content added
Line 1,079:
</pre>
=={{header|VBA}}==
{{trans|Phix}}
<lang vb>Private Function factors(n As Integer) As Collection
Dim f As New Collection
For i = 1 To Sqr(n)
If n Mod i = 0 Then
f.Add i
If n / i <> i Then f.Add n / i
End If
Next i
f.Add n
Set factors = f
End Function
Public Sub anti_primes()
Dim n As Integer, maxd As Integer
Dim res As New Collection, lenght As Integer
Dim lf As Integer
n = 1: maxd = -1
Length = 0
Do While res.count < 20
lf = factors(n).count
If lf > maxd Then
res.Add n
maxd = lf
End If
n = n + IIf(n > 1, 2, 1)
Loop
Debug.Print "The first 20 anti-primes are:";
For Each x In res
Debug.Print x;
Next x
End Sub</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|zkl}}==
{{trans|Perl6}}
|