Private Sub Command1_Click()
For i = 1 To 1000
If is_ws(i) Then
Print Trim(Str(i)); ": its factors are 1";
For j = 2 To i \ 2
If i Mod j = 0 Then Print ","; Trim(Str(j));
Next j
End If
Next i
End Sub
Function is_ws(n) As Boolean
s = 0
For i = 1 To n \ 2
If n Mod i = 0 Then s = s + i
Next i
is_ws = (s = n)
End Function