Abundant odd numbers: Difference between revisions

Content added Content deleted
No edit summary
(Added uBasic/4tH version)
Line 6,302: Line 6,302:
first odd abundant number over 1 billion: 1000000575, sigma: 1083561009</pre>
first odd abundant number over 1 billion: 1000000575, sigma: 1083561009</pre>


=={{header|uBasic/4tH}}==
{{trans|c}}
<lang>c = 0
For n = 1 Step 2 While c < 25
If n < FUNC(_SumProperDivisors(n)) Then
c = c + 1
Print Using "_#"; c; Using " ____#"; n
EndIf
Next
For n = n Step 2 While c < 1000
If n < FUNC(_SumProperDivisors(n)) Then c = c + 1
Next
Print "\nThe one thousandth abundant odd number is: "; n
For n = 1000000001 Step 2)
Until n < FUNC(_SumProperDivisors(n))
Next
Print "The first abundant odd number above one billion is: "; n
End

' The following function is for odd numbers ONLY

_SumProperDivisors
Param (1)
Local (3)
b@ = 1
For c@ = 3 To FUNC(_Sqrt(a@)) Step 2
If (a@ % c@) = 0 Then b@ = b@ + c@ + Iif (c@ = Set(d@, a@/c@), 0, d@)
Next
Return (b@)

_Sqrt
Param (1)
Local (3)

Let b@ = 1
Let c@ = 0

Do Until b@ > a@
Let b@ = b@ * 4
Loop

Do While b@ > 1
Let b@ = b@ / 4
Let d@ = a@ - c@ - b@
Let c@ = c@ / 2
If d@ > -1 Then
Let a@ = d@
Let c@ = c@ + b@
Endif
Loop

Return (c@)</lang>
{{out}}
<pre> 1 945
2 1575
3 2205
4 2835
5 3465
6 4095
7 4725
8 5355
9 5775
10 5985
11 6435
12 6615
13 6825
14 7245
15 7425
16 7875
17 8085
18 8415
19 8505
20 8925
21 9135
22 9555
23 9765
24 10395
25 11025

The one thousandth abundant odd number is: 492977
The first abundant odd number above one billion is: 1000000575

0 OK, 0:479
</pre>
=={{header|Visual Basic .NET}}==
=={{header|Visual Basic .NET}}==
{{Trans|ALGOL 68}}
{{Trans|ALGOL 68}}