The legendary baseball player Babe Ruth1 hit an unseen lifetime record of 714 home runs. This record stood until April 8, 1974, when it was surpassed by Hank Aaron2's record-breaking 715th home run. Carl Pomerance — mathematician at the University of Georgia at the time Aaron broke Ruth's record — introduced a new concept in mathematics based on this event. The inspiration came when a student of one of Pomerance's colleagues noticed that the sums of the prime factors of 714 and 715 are equal. He therefore defined a Ruth-Aaron pair as a pair of consecutive natural numbers $$(n, n + 1)$$ such that the sums of the prime factors of $$n$$ and $$n + 1$$ are equal.
Each positive integer $$n \in \mathbb{N_0}$$ can be written as a product of prime numbers. \[\begin{eqnarray}10 &=& 2 \times 5\\12 &=& 2 \times 2 \times 3\\13 &=& 13\\100 &=& 2 \times 2 \times 5 \times 5 \end{eqnarray}\] This decomposition in prime factors is unique3, except for the order of the prime factors. The pair $$(714, 715)$$ is a Ruth-Aaron pair as \[\begin{eqnarray}714 &=& 2 \times 3 \times 7 \times 17\\715 &=& 5 \times 11 \times 13\end{eqnarray}\] and $$2 + 3 + 7 + 17 = 29 = 5 + 11 + 13$$. The pair $$(9, 10)$$ is not a Ruth-Aaron pair as $$2 + 5 \not= 3 + 3$$.
Write a function isPrime that takes a positive integer $$n \in \mathbb{N_0}$$. The function must return a Boolean that indicates whether or not $$n$$ is prime.
Write a function primeFactors that takes a positive integer $$n \in \mathbb{N_0}$$. The function must return the list of prime factors of $$n$$, sorted in increasing order.
Write a function isRuthAaron that takes two positive integers $$m, n \in \mathbb{N_0}$$. The function must return a Boolean that indicates whether or not the pair $$(m, n)$$ is a Ruth-Aaron pair. Note that $$(m, n)$$ can only be a Ruth-Aaron pair if the integer $$n$$ immediately follows the integer $$m$$. The pair $$(714, 715)$$ is a Ruth-Aaron pair, but the pair $$(715, 714)$$ isn't.
>>> isPrime(2)
True
>>> isPrime(6)
False
>>> isPrime(12)
False
>>> primeFactors(12)
[2, 2, 3]
>>> primeFactors(17)
[17]
>>> primeFactors(18)
[2, 3, 3]
>>> isRuthAaron(5, 6)
True
>>> isRuthAaron(10, 11)
False
>>> isRuthAaron(15, 16)
True
>>> isRuthAaron(8281, 8280)
False
Babai L, Pomerance C, Vértesi P (1998). The Mathematics of Paul Erdos. Notices Amer. Math. Soc. 45, 19-23. 4
Drost JL (1997). Ruth/Aaron Pairs. J. Recr. Math. 28(2), 120-122.
Erdos P, Pomerance C (1978). On the Largest Prime Factors of $$n$$ and $$n+1$$. Aeq. Math. 17, 311-321. 5
Hoffman P (1998). The Man Who Loved Only Numbers: The Story of Paul Erdos and the Search for Mathematical Truth. New York: Hyperion. 6
Mackenzie D (1997). Mathematics: Homage to an Itinerant Master. Science 275, 759. 7
Nelson C, Penney DE, Pomerance C (1974). 714 and 715. J. Recr. Math. 7, 87-89. 8
Peterson I (2005). MathTrek: Playing with Ruth-Aaron Pairs. Sci. News 168, 2005. 9
Pomerance C (2002). Ruth-Aaron Numbers Revisited. In Paul Erdos and his Mathematics. I. Papers from the Conference Held in Budapest, July 4-11, 1999 (Ed. G. Halász, L. Lovász, M. Simonovits, and V. T. Sós). Berlin: Springer-Verlag, 567-579. 10