Perfect numbers P46540


Statement
 

pdf   zip

html

Once, Beremiz explained to a sheikh what are perfect numbers: those whose sum of positive divisors, the number excluded, equals the number itself.

For instance, 6 is perfect, because all its positive divisors (except 6 itself) are 1, 2 and 3, and 1 + 2 + 3 = 6. Other perfect numbers are 28 and 496.

Input

Input consists of several natural numbers n, all between 1 and 1012.

Output

For every n, print the difference in absolute value between the sum of the divisors of n (n excluded), and n. Note that we can interpret this difference as the “imperfection” of the number, which is 0 only for perfect numbers.

Observation

At the time of the creation of this problem (year 2013), only 48 perfect numbers are known, all even. The largest one has about 35 million digits. It is unknown whether there are infinitely many perfect numbers, or if any of them is odd.

Public test cases
  • Input

    6
    5
    100
    496
    497
    1
    1000000000000
    999962000357
    999999999989
    

    Output

    0
    4
    17
    0
    418
    1
    499694822171
    999960000394
    999999999988
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Salvador Roura
    Original language
    Spanish
    Other languages
    Spanish
    Official solutions
    C++
    User solutions
    C++