A pair of numbers are called friends if they are different and the sum of all the positive divisors of each number (included 1, but not included the own number) is equal to the other number.
For instance, 2620 and 2924 are friends: the divisors of 2620 (not included 2620) are 1, 2, 4, 5, 10, 20, 131, 262, 524, 655 and 1310, which sum is 2924. The divisors of 2924 (not included 2924) are 1, 2, 4, 17, 34, 43, 68, 86, 172, 731 and 1462, which sum is 2620.
Your task is to write a program that reads a sequence of pairs of natural numbers greater or equal than 2, and prints the friend pairs.
Your program must include two functions:
that returns the sum of the positive divisors of the natural number \(\mbox {|a|} \ge 2\) that are strictly less than a, and
that indicates if two natural numbers \(\mbox {|a|} \ge 2\) and \(\mbox {|b|} \ge 2\) are friends.
Input
The input is a sequence \(a_1, b_1, a_2, b_2, \dots , a_n, b_n\) of \(n\) pairs of natural numbers greater or equal than 2, with \(n \ge 0\).
Output
Your program must print one line, which contains each pair of numbers \(a_i~b_i\) that are friends (including repetitions if necessary). The pairs must be written separated by commas and in brackets, following the format of the instances.
© Jutge.org, 2006–2024
Input
1345 6721 2924 2620 15 2 220 284 220 284
Output
(2924 2620),(220 284),(220 284)
Input
Output
Input
8 8 1184 1210 6666 9999 6 6
Output
(1184 1210)