Ruth-Aaron numbers: Difference between revisions

Added FreeBasic
(Added FreeBasic)
Line 321:
13775 18655 21183 24024 24432 24880 25839 26642 35456 40081
</pre>
 
=={{header|FreeBASIC}}==
{{trans|XPL0}}
<syntaxhighlight lang="vb">Function DivSum(N As Integer, AllDiv As Boolean) As Integer
Dim As Integer Q, F = 2, F0 = 0, S1 = 0
Do
Q = N/F
If (N Mod F) = 0 Then
If AllDiv Then
S1 += F
Else
If F <> F0 Then S1 += F : F0 = F
End If
N = Q
Else
F += 1
End If
Loop Until F > N
Return S1
End Function
 
Sub Ruth_Aaron(AllDiv As Boolean)
Dim As Integer S, C = 0, S0 = 0, N = 2
Do
S = DivSum(N, AllDiv)
If S = S0 Then
Print Using "######"; N-1;
C += 1
If (C Mod 10) = 0 Then Print
End If
S0 = S
N += 1
Loop Until C >= 30
End Sub
 
Print "First 30 Ruth-Aaron numbers (factors):"
Ruth_Aaron(True) ' https://oeis.org/A039752
Print !"\nFirst 30 Ruth-Aaron numbers (divisors):"
Ruth_Aaron(False) ' https://oeis.org/A006145
 
Sleep</syntaxhighlight>
{{out}}
<pre>First 30 Ruth-Aaron numbers (factors):
5 8 15 77 125 714 948 1330 1520 1862
2491 3248 4185 4191 5405 5560 5959 6867 8280 8463
10647 12351 14587 16932 17080 18490 20450 24895 26642 26649
 
First 30 Ruth-Aaron numbers (divisors):
5 24 49 77 104 153 369 492 714 1682
2107 2299 2600 2783 5405 6556 6811 8855 9800 12726
13775 18655 21183 24024 24432 24880 25839 26642 35456 40081</pre>
 
=={{header|Go}}==
2,127

edits