Difference of sums
Among the numbers 1 to M, add up the ones divisible by N and, separately, the ones not divisible by N. Print the absolute difference of the two sums.
Reported in: Accenture (Aug 2022), Deloitte (memory-based)
Input
One line: N and M.
Output
The absolute difference.
Constraints
1 ≤ N, M ≤ 10^6.
Example 1
Input:
4 20
Output:
90Example 2
Input:
3 10
Output:
19Hint: Loop once, or use the formula for the sum of multiples.