30 lines
501 B
Plaintext
30 lines
501 B
Plaintext
For n = 2 To 10000 Step 2
|
|
VerifyIfPerfect()
|
|
If isPerfect = 1 Then
|
|
TextWindow.WriteLine(n)
|
|
EndIf
|
|
EndFor
|
|
|
|
Sub VerifyIfPerfect
|
|
s = 1
|
|
sqrN = Math.SquareRoot(n)
|
|
If Math.Remainder(n, 2) = 0 Then
|
|
s = s + 2 + Math.Floor(n / 2)
|
|
EndIf
|
|
i = 3
|
|
while i <= sqrN - 1
|
|
If Math.Remainder(n, i) = 0 Then
|
|
s = s + i + Math.Floor(n / i)
|
|
EndIf
|
|
i = i + 1
|
|
EndWhile
|
|
If i * i = n Then
|
|
s = s + i
|
|
EndIf
|
|
If n = s Then
|
|
isPerfect = 1
|
|
Else
|
|
isPerfect = 0
|
|
EndIf
|
|
EndSub
|