Abundant, deficient and perfect number classifications: Difference between revisions

Line 780:
END !Done.
</lang>
 
=={{header|FreeBASIC}}==
<lang freebasic>
' FreeBASIC v1.05.0 win64
 
Function SumProperDivisors(number As Integer) As Integer
If Number < 2 Then Return 0
Dim sum As Integer = 0
For i As Integer = 1 To Number \ 2
If Number Mod i = 0 Then sum += i
Next
Return sum
End Function
 
Dim As Integer sum, deficient, perfect, abundant
 
For n As Integer = 1 To 20000
sum = SumProperDivisors(n)
If sum < n Then
deficient += 1
ElseIf sum = n Then
perfect += 1
Else
abundant += 1
EndIf
Next
 
Print "The classification of the numbers from 1 to 20,000 is as follows : "
Print
Print "Deficient = "; deficient
Print "Perfect = "; perfect
Print "Abundant = "; abundant
Print
Print "Press any key to exit the program"
Sleep
End
</lang>
 
{{out}}
<pre>
The classification of the numbers from 1 to 20,000 is as follows :
 
Deficient = 15043
Perfect = 4
Abundant = 4953
</pre>
 
=={{header|GFA Basic}}==
9,490

edits