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