Ruth-Aaron Pairs

August 11, 2017

The first exercise computes the primorials in order, then checks the square root to determine if the primorial is of the correct form:

(define (ruth-aaron-multiplicative limit)
 (let ((ps (primegen)))
    (let loop ((primorial 1))
      (when (< primorial limit)
        (let ((x (isqrt primorial)))
          (when (= (* x (+ x 1)) primorial)
            (display (list x (+ x 1))) (newline))
          (loop (* primorial (ps))))))))
> (ruth-aaron-multiplicative 520000)
(1 2)
(2 3)
(5 6)
(14 15)
(714 715)

The primorials grow very quickly, and Pomerance checked them up to a very high number, so it is conjectured that the list above is the complete list of multiplicative Ruth-Aaron pairs.

For the second exercise, we loop from 1 to a requested limit, keeping track of factors and comparing each to the prior; here are both possibilities:

(define (ruth-aaron-additive-repeating limit)
  (let loop ((n 1) (fs (factors 1)) (sum-fs (sum (factors 1))))
    (when (< n limit)
      (let* ((n+1 (+ n 1)) (fs+1 (factors n+1)) (sum-fs+1 (sum fs+1)))
        (when (= sum-fs sum-fs+1) (display (list n (+ n 1))) (newline))
          (loop n+1 fs+1 sum-fs+1))))))
> (ruth-aaron-additive-repeating 720)
(5 6)
(8 9)
(15 16)
(77 78)
(125 126)
(714 715)
(define (ruth-aaron-additive-distinct limit)
  (let loop ((n 1) (fs (factors 1)) (sum-fs (sum (unique = (factors 1)))))
    (when (< n limit)
      (let* ((n+1 (+ n 1)) (fs+1 (factors n+1)) (sum-fs+1 (sum (unique = fs+1))))
        (when (= sum-fs sum-fs+1) (display (list n (+ n 1))) (newline))
          (loop n+1 fs+1 sum-fs+1))))))
> (ruth-aaron-additive-distinct 720)
(5 6)
(24 25)
(49 50)
(77 78)
(104 105)
(153 154)
(369 370)
(492 493)
(714 715)

Pomerance and Erdös proved that both these sequences are infinite.

You can run the program at http://ideone.com/1GBZ1C.

Advertisements

Pages: 1 2

2 Responses to “Ruth-Aaron Pairs”

  1. Paul said

    In Python.

    def aaron1(limit=1000):
        lim2 = limit ** 2
        prgen = primegen()
        N = next(prgen) * next(prgen) * next(prgen)
        while N < lim2:
            cand1 = isqrt(N)
            if cand1 * (cand1 + 1) == N:
                yield cand1, cand1 + 1
            N *= next(prgen)
    
    def aaron_rep(limit = 1000):
        lastsum = 2
        for n in range(3, limit):
            newsum = sum(td_factors(n))
            if lastsum == newsum:
                yield n-1, n
            lastsum = newsum
    
    def aaron_uni(limit = 1000):
        lastsum = 2
        for n in range(3, limit):
            newsum = sum(set(td_factors(n)))
            if lastsum == newsum:
                yield n-1, n
            lastsum = newsum
    
    print(list(aaron1()))
    print(list(aaron_rep()))
    print(list(aaron_uni()))
    
  2. Zack said

    The first exercise seemed quite time consuming, so I focused on the other two.
    Code: https://app.box.com/s/0o1p2xrt4x8uf68h5j547x1cywh4dtfq
    If the main() function is run with distinct set to true, it only checks for distinct factors. The second parameter of the function has to do with the highest number to check.

    Sample output:
    julia> main(true)
    5, 6 5
    24, 25 5
    49, 50 7
    77, 78 18

    julia> main(false)
    5, 6 5
    8, 9 6
    15, 16 8
    77, 78 18

    The last number corresponds to the factor sum.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: