A Ruth–Aaron pair consists of two consecutive integers (e.g., 714 and 715) for which the sums of the prime divisors of each integer are equal. So called because 714 is Babe Ruth's lifetime home run record; Hank Aaron's 715th home run broke this record and 714 and 715 have the same prime divisor sum.



A Ruth–Aaron triple consists of three consecutive integers with the same properties.



There is a second variant of Ruth–Aaron numbers, one which uses prime factors rather than prime divisors. The difference; divisors are unique, factors may be repeated. The 714, 715 pair appears in both, so the name still fits.



It is common to refer to each Ruth–Aaron group by the first number in it.



Task
 Find and show, here on this page, the first 30 Ruth-Aaron numbers (factors).
 Find and show, here on this page, the first 30 Ruth-Aaron numbers (divisors).


Stretch
 Find and show the first Ruth-Aaron triple (factors).
 Find and show the first Ruth-Aaron triple (divisors).


See also
Wikipedia: Ruth–Aaron pair
OEIS:A006145 - Ruth-Aaron numbers (1): sum of prime divisors of n = sum of prime divisors of n+1
OEIS:A039752 - Ruth-Aaron numbers (2): sum of prime divisors of n = sum of prime divisors of n+1 (both taken with multiplicity)
with javascript_semantics
procedure ruth_aaron(bool d, integer n=30, l=2, i=1)
    string fd = iff(d?"divisors":"factors"),
           ns = iff(n=1?"":sprintf(" %d",n)),
           ss = iff(n=1?"":"s"),
           nt = iff(l=2?"number":"triple")
    printf(1,"First%s Ruth-Aaron %s%s (%s):\n",{ns,nt,ss,fd})
    integer prev = -1, k = i, c = 0
    while n do
        sequence f = prime_factors(k,true,-1)
        if d then f = unique(f) end if
        integer s = sum(f)
        if s and s=prev then
            c += 1
            if c=l-1 then
                printf(1,"%d ",k-c)
                n -= 1
            end if
        else
            c = 0
        end if
        prev = s
        k += 1
    end while
    printf(1,"\n\n")
end procedure
atom t0 = time()
ruth_aaron(false)   -- https://oeis.org/A039752
ruth_aaron(true)    -- https://oeis.org/A006145
ruth_aaron(false, 1, 3) -- (2.1s)
-- give this one a little leg-up :-) ...
ruth_aaron(true, 1, 3, 89460000) -- (0.1s)
--ruth_aaron(true, 1, 3) -- (24 minutes 30s)
