Skip to content

Commit 0c6fe30

Browse files
authored
Create Divisible and Non-divisible Sums Difference.java
1 parent 187962d commit 0c6fe30

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Solution {
2+
public int differenceOfSums(int n, int m) {
3+
int num1 = n * (n + 1) / 2;
4+
int num2 = n / m;
5+
num2 = m * num2 * (num2 + 1) / 2;
6+
return num1 - 2 * num2;
7+
}
8+
}

0 commit comments

Comments
 (0)