P0003. Friend numbers P55307


Statement
 

pdf   zip

html

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:

Public test cases
  • 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)
    
  • Information
    Author
    Professorat de P1
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++