## 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

In Python.

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.