Compute the difference between the sum of numbers from 1 to n that are not divisible by m and the sum of numbers that are divisible by m.
Given two integers n and m, consider all integers from 1 to n inclusive.
A be the sum of all numbers in this range that are not divisible by m.B be the sum of all numbers in this range that are divisible by m.Return A - B.
You should compute the result for the given pair (n, m).
x is divisible by m if x % m == 0.1 and ends at n.n and m.A - B.1 <= n1 <= mExample 1
Input
n = 10, m = 3
Output
19
Explanation
Numbers not divisible by 3 are 1, 2, 4, 5, 7, 8, 10, whose sum is 37. Numbers divisible by 3 are 3, 6, 9, whose sum is 18. The difference is 37 - 18 = 19.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.