#P7788. Sum of Imperfection Values
Sum of Imperfection Values
Sum of Imperfection Values
A positive integer N is called perfect if it is equal to the sum of its proper divisors (divisors strictly less than N). For example, since \(28=1+2+4+7+14\), 28 is a perfect number.
We define the imperfection value \(F(N)\) as the absolute difference between \(N\) and the sum of all its proper divisors. In other words,
\(F(N)= \left|N - \sum_{d|N,\; d<N}d\right|\)
For example:
- \(F(6)= |6 - (1+2+3)| = 0\)
- \(F(11)= |11 - 1| = 10\)
- \(F(24)= |24 - (1+2+3+4+6+8+12)| = 12\)
Given two positive integers \(A\) and \(B\), compute the sum \(F(A) + F(A+1) + \dots + F(B)\).
inputFormat
The input consists of two positive integers \(A\) and \(B\) (\(A \leq B\)) separated by space or newline.
outputFormat
Output a single integer which is the sum \(F(A) + F(A+1) + \dots + F(B)\).
sample
1 5
9