---
# System prepended metadata

title: 2894. Divisible and Non-divisible Sums Difference
tags: [Leetcode, Easy, Math]

---

Link: https://leetcode.com/problems/divisible-and-non-divisible-sums-difference/
## Code
```python=
class Solution:
    def differenceOfSums(self, n: int, m: int) -> int:
        num2 = 0
        for i in range(1, n+1):
            if i%m == 0:
                num2 += i
        return ((1+n)*n)//2-2*num2
```