Algorithms
Easy
2894
3172
Divisible and Non-divisible Sums Difference
divisible-and-non-divisible-sums-difference
"""
You are given positive integers n and m.

Define two integers, num1 and num2, as follows:

 * num1: The sum of all integers in the range [1, n] that are not divisible by m.
 * num2: The sum of all integers in the range [1, n] that are divisible by m.

Return the integer num1 - num2.

Example 1:

Input: n = 10, m = 3
Output: 19
Explanation: In the given example:
- Integers in the range [1, 10] that are not divisible by 3 are [1,2,4,5,7,8,10], num1 is the sum of those integers = 37.
- Integers in the range [1, 10] that are divisible by 3 are [3,6,9], num2 is the sum of those integers = 18.
We return 37 - 18 = 19 as the answer.

Example 2:

Input: n = 5, m = 6
Output: 15
Explanation: In the given example:
- Integers in the range [1, 5] that are not divisible by 6 are [1,2,3,4,5], num1 is the sum of those integers = 15.
- Integers in the range [1, 5] that are divisible by 6 are [], num2 is the sum of those integers = 0.
We return 15 - 0 = 15 as the answer.

Example 3:

Input: n = 5, m = 1
Output: -15
Explanation: In the given example:
- Integers in the range [1, 5] that are not divisible by 1 are [], num1 is the sum of those integers = 0.
- Integers in the range [1, 5] that are divisible by 1 are [1,2,3,4,5], num2 is the sum of those integers = 15.
We return 0 - 15 = -15 as the answer.


Constraints:

 * 1 <= n, m <= 1000
"""
class Solution:
    def differenceOfSums(self, n: int, m: int) -> int:
        
You are given positive integers n and m.

Define two integers, num1 and num2, as follows:

 * num1: The sum of all integers in the range [1, n] that are not divisible by m.
 * num2: The sum of all integers in the range [1, n] that are divisible by m.

Return the integer num1 - num2.

Example 1:

Input: n = 10, m = 3
Output: 19
Explanation: In the given example:
- Integers in the range [1, 10] that are not divisible by 3 are [1,2,4,5,7,8,10], num1 is the sum of those integers = 37.
- Integers in the range [1, 10] that are divisible by 3 are [3,6,9], num2 is the sum of those integers = 18.
We return 37 - 18 = 19 as the answer.

Example 2:

Input: n = 5, m = 6
Output: 15
Explanation: In the given example:
- Integers in the range [1, 5] that are not divisible by 6 are [1,2,3,4,5], num1 is the sum of those integers = 15.
- Integers in the range [1, 5] that are divisible by 6 are [], num2 is the sum of those integers = 0.
We return 15 - 0 = 15 as the answer.

Example 3:

Input: n = 5, m = 1
Output: -15
Explanation: In the given example:
- Integers in the range [1, 5] that are not divisible by 1 are [], num1 is the sum of those integers = 0.
- Integers in the range [1, 5] that are divisible by 1 are [1,2,3,4,5], num2 is the sum of those integers = 15.
We return 0 - 15 = -15 as the answer.


Constraints:

 * 1 <= n, m <= 1000


Please complete the code below to solve above prblem:
```python
class Solution:
    def differenceOfSums(self, n: int, m: int) -> int:
        
```

my_solution = Solution()

test_input = { "n": 10, "m": 3 }
assert my_solution.differenceOfSums(**test_input) == 19

test_input = { "n": 5, "m": 6 }
assert my_solution.differenceOfSums(**test_input) == 15

test_input = { "n": 5, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -15

test_input = { "n": 15, "m": 9 }
assert my_solution.differenceOfSums(**test_input) == 102

test_input = { "n": 8, "m": 10 }
assert my_solution.differenceOfSums(**test_input) == 36

test_input = { "n": 23, "m": 36 }
assert my_solution.differenceOfSums(**test_input) == 276

test_input = { "n": 1, "m": 32 }
assert my_solution.differenceOfSums(**test_input) == 1

test_input = { "n": 36, "m": 7 }
assert my_solution.differenceOfSums(**test_input) == 456

test_input = { "n": 3, "m": 8 }
assert my_solution.differenceOfSums(**test_input) == 6

test_input = { "n": 4, "m": 2 }
assert my_solution.differenceOfSums(**test_input) == -2

test_input = { "n": 9, "m": 7 }
assert my_solution.differenceOfSums(**test_input) == 31

test_input = { "n": 20, "m": 9 }
assert my_solution.differenceOfSums(**test_input) == 156

test_input = { "n": 3, "m": 19 }
assert my_solution.differenceOfSums(**test_input) == 6

test_input = { "n": 6, "m": 16 }
assert my_solution.differenceOfSums(**test_input) == 21

test_input = { "n": 6, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -21

test_input = { "n": 5, "m": 25 }
assert my_solution.differenceOfSums(**test_input) == 15

test_input = { "n": 9, "m": 3 }
assert my_solution.differenceOfSums(**test_input) == 9

test_input = { "n": 8, "m": 23 }
assert my_solution.differenceOfSums(**test_input) == 36

test_input = { "n": 17, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -153

test_input = { "n": 18, "m": 9 }
assert my_solution.differenceOfSums(**test_input) == 117

test_input = { "n": 22, "m": 30 }
assert my_solution.differenceOfSums(**test_input) == 253

test_input = { "n": 1, "m": 42 }
assert my_solution.differenceOfSums(**test_input) == 1

test_input = { "n": 33, "m": 19 }
assert my_solution.differenceOfSums(**test_input) == 523

test_input = { "n": 7, "m": 19 }
assert my_solution.differenceOfSums(**test_input) == 28

test_input = { "n": 12, "m": 24 }
assert my_solution.differenceOfSums(**test_input) == 78

test_input = { "n": 26, "m": 25 }
assert my_solution.differenceOfSums(**test_input) == 301

test_input = { "n": 9, "m": 16 }
assert my_solution.differenceOfSums(**test_input) == 45

test_input = { "n": 1, "m": 8 }
assert my_solution.differenceOfSums(**test_input) == 1

test_input = { "n": 29, "m": 42 }
assert my_solution.differenceOfSums(**test_input) == 435

test_input = { "n": 2, "m": 11 }
assert my_solution.differenceOfSums(**test_input) == 3

test_input = { "n": 36, "m": 10 }
assert my_solution.differenceOfSums(**test_input) == 546

test_input = { "n": 45, "m": 4 }
assert my_solution.differenceOfSums(**test_input) == 507

test_input = { "n": 3, "m": 7 }
assert my_solution.differenceOfSums(**test_input) == 6

test_input = { "n": 6, "m": 12 }
assert my_solution.differenceOfSums(**test_input) == 21

test_input = { "n": 3, "m": 4 }
assert my_solution.differenceOfSums(**test_input) == 6

test_input = { "n": 8, "m": 28 }
assert my_solution.differenceOfSums(**test_input) == 36

test_input = { "n": 18, "m": 23 }
assert my_solution.differenceOfSums(**test_input) == 171

test_input = { "n": 11, "m": 6 }
assert my_solution.differenceOfSums(**test_input) == 54

test_input = { "n": 35, "m": 10 }
assert my_solution.differenceOfSums(**test_input) == 510

test_input = { "n": 29, "m": 18 }
assert my_solution.differenceOfSums(**test_input) == 399

test_input = { "n": 1, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -1

test_input = { "n": 12, "m": 8 }
assert my_solution.differenceOfSums(**test_input) == 62

test_input = { "n": 7, "m": 12 }
assert my_solution.differenceOfSums(**test_input) == 28

test_input = { "n": 17, "m": 3 }
assert my_solution.differenceOfSums(**test_input) == 63

test_input = { "n": 16, "m": 15 }
assert my_solution.differenceOfSums(**test_input) == 106

test_input = { "n": 18, "m": 3 }
assert my_solution.differenceOfSums(**test_input) == 45

test_input = { "n": 4, "m": 12 }
assert my_solution.differenceOfSums(**test_input) == 10

test_input = { "n": 3, "m": 21 }
assert my_solution.differenceOfSums(**test_input) == 6

test_input = { "n": 15, "m": 4 }
assert my_solution.differenceOfSums(**test_input) == 72

test_input = { "n": 9, "m": 39 }
assert my_solution.differenceOfSums(**test_input) == 45

test_input = { "n": 19, "m": 18 }
assert my_solution.differenceOfSums(**test_input) == 154

test_input = { "n": 2, "m": 4 }
assert my_solution.differenceOfSums(**test_input) == 3

test_input = { "n": 41, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -861

test_input = { "n": 3, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -6

test_input = { "n": 16, "m": 13 }
assert my_solution.differenceOfSums(**test_input) == 110

test_input = { "n": 32, "m": 10 }
assert my_solution.differenceOfSums(**test_input) == 408

test_input = { "n": 41, "m": 34 }
assert my_solution.differenceOfSums(**test_input) == 793

test_input = { "n": 33, "m": 40 }
assert my_solution.differenceOfSums(**test_input) == 561

test_input = { "n": 36, "m": 8 }
assert my_solution.differenceOfSums(**test_input) == 506

test_input = { "n": 8, "m": 34 }
assert my_solution.differenceOfSums(**test_input) == 36

test_input = { "n": 40, "m": 12 }
assert my_solution.differenceOfSums(**test_input) == 676

test_input = { "n": 28, "m": 9 }
assert my_solution.differenceOfSums(**test_input) == 298

test_input = { "n": 20, "m": 6 }
assert my_solution.differenceOfSums(**test_input) == 138

test_input = { "n": 13, "m": 6 }
assert my_solution.differenceOfSums(**test_input) == 55

test_input = { "n": 2, "m": 37 }
assert my_solution.differenceOfSums(**test_input) == 3

test_input = { "n": 14, "m": 17 }
assert my_solution.differenceOfSums(**test_input) == 105

test_input = { "n": 35, "m": 4 }
assert my_solution.differenceOfSums(**test_input) == 342

test_input = { "n": 2, "m": 14 }
assert my_solution.differenceOfSums(**test_input) == 3

test_input = { "n": 5, "m": 2 }
assert my_solution.differenceOfSums(**test_input) == 3

test_input = { "n": 7, "m": 7 }
assert my_solution.differenceOfSums(**test_input) == 14

test_input = { "n": 12, "m": 26 }
assert my_solution.differenceOfSums(**test_input) == 78

test_input = { "n": 14, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -105

test_input = { "n": 2, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -3

test_input = { "n": 20, "m": 3 }
assert my_solution.differenceOfSums(**test_input) == 84

test_input = { "n": 8, "m": 27 }
assert my_solution.differenceOfSums(**test_input) == 36

test_input = { "n": 1, "m": 12 }
assert my_solution.differenceOfSums(**test_input) == 1

test_input = { "n": 13, "m": 19 }
assert my_solution.differenceOfSums(**test_input) == 91

test_input = { "n": 7, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -28

test_input = { "n": 31, "m": 4 }
assert my_solution.differenceOfSums(**test_input) == 272

test_input = { "n": 11, "m": 25 }
assert my_solution.differenceOfSums(**test_input) == 66

test_input = { "n": 5, "m": 19 }
assert my_solution.differenceOfSums(**test_input) == 15

test_input = { "n": 33, "m": 12 }
assert my_solution.differenceOfSums(**test_input) == 489

test_input = { "n": 4, "m": 26 }
assert my_solution.differenceOfSums(**test_input) == 10

test_input = { "n": 1, "m": 24 }
assert my_solution.differenceOfSums(**test_input) == 1

test_input = { "n": 13, "m": 20 }
assert my_solution.differenceOfSums(**test_input) == 91

test_input = { "n": 6, "m": 8 }
assert my_solution.differenceOfSums(**test_input) == 21

test_input = { "n": 8, "m": 26 }
assert my_solution.differenceOfSums(**test_input) == 36

test_input = { "n": 4, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -10

test_input = { "n": 1, "m": 6 }
assert my_solution.differenceOfSums(**test_input) == 1

test_input = { "n": 2, "m": 25 }
assert my_solution.differenceOfSums(**test_input) == 3

test_input = { "n": 4, "m": 4 }
assert my_solution.differenceOfSums(**test_input) == 2

test_input = { "n": 8, "m": 2 }
assert my_solution.differenceOfSums(**test_input) == -4

test_input = { "n": 15, "m": 21 }
assert my_solution.differenceOfSums(**test_input) == 120

test_input = { "n": 1, "m": 2 }
assert my_solution.differenceOfSums(**test_input) == 1

test_input = { "n": 12, "m": 2 }
assert my_solution.differenceOfSums(**test_input) == -6

test_input = { "n": 40, "m": 14 }
assert my_solution.differenceOfSums(**test_input) == 736

test_input = { "n": 14, "m": 19 }
assert my_solution.differenceOfSums(**test_input) == 105

test_input = { "n": 18, "m": 1 }
assert my_solution.differenceOfSums(**test_input) == -171

test_input = { "n": 1, "m": 28 }
assert my_solution.differenceOfSums(**test_input) == 1

test_input = { "n": 31, "m": 18 }
assert my_solution.differenceOfSums(**test_input) == 460