Sum of Remainders
Submit solution
Points:
1
Time limit:
1.0s
Memory limit:
256M
Problem type
Allowed languages
C++, Python
Sum of Remainders Problem
Given positive integers n and k, compute
J(n, k) = (k mod 1) + (k mod 2) + (k mod 3) + … + (k mod n).
For example,
J(5, 3) = 3 mod 1 + 3 mod 2 + 3 mod 3 + 3 mod 4 + 3 mod 5
= 0 + 1 + 0 + 3 + 3 = 7.
Input Format
A single line containing two integers n and k.
Output Format
A single integer — J(n, k).
Data Range
1 ≤ n, k ≤ 109
Sample Input
5 3
Sample Output
7
Comments