A number is perfect when it equals the sum of its divisors that are smaller than itself. For example, 28=1+2+4+7+14, so 28 is perfect.
Starting from that definition, the imperfection of a natural number N, written f(N), is the absolute difference between N and the sum of the divisors of N that are smaller than N. A perfect number has imperfection 0, and every other natural number has a positive imperfection. 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∣=12
Given positive integers A and B, write a program that computes the sum of the imperfections of all numbers from A to B, that is f(A)+f(A+1)+⋯+f(B).