Primtalsgenerator
Sub prim()
Sheets("Ark1").Select
For n = 2 To 64000
s = 1
For f = 1 To r
p = Cells(f, 1)
If n Mod p = 0 Then
s = 0
Exit For
End If
Next f
If s = 1 Then
r = r + 1
Cells(r, 1) = n
End If
Next n
End Sub
Visual Basic i Excel
Sheets("Ark1").Select
For n = 2 To 64000
s = 1
For f = 1 To r
p = Cells(f, 1)
If n Mod p = 0 Then
s = 0
Exit For
End If
Next f
If s = 1 Then
r = r + 1
Cells(r, 1) = n
End If
Next n
End Sub
Visual Basic i Excel