24 lines
634 B
Plaintext
24 lines
634 B
Plaintext
Const max = 1 Shl 19
|
|
|
|
Function frc(numerador As Double, denominador As Double = 1) As Double
|
|
Return numerador / denominador
|
|
End Function
|
|
|
|
Function isPerfect(valorEval As Uinteger) As Boolean
|
|
Dim As Double sum = frc(1, valorEval)
|
|
Dim As Uinteger max2 = Int(Sqr(valorEval))
|
|
For factor As Uinteger = 2 To max2
|
|
If (valorEval Mod factor) = 0 Then
|
|
sum += frc(1, factor) + frc(1, valorEval \ factor)
|
|
End If
|
|
Next
|
|
Return sum = frc(1)
|
|
End Function
|
|
|
|
Dim As Double t0 = Timer
|
|
For valorEval As Uinteger = 2 To max - 1
|
|
If isPerfect(valorEval) Then Print valorEval & " is perfect"
|
|
Next
|
|
|
|
Sleep
|