We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 55f3426 commit db502fbCopy full SHA for db502fb
2894. Divisible and Non-divisible Sums Difference
@@ -0,0 +1,11 @@
1
+class Solution {
2
+public:
3
+ int differenceOfSums(int n, int m) {
4
+ // we need to find S(n)-2*(divisibles)
5
+
6
+ // no of divisibles
7
+ int x=n/m;
8
9
+ return (n*(n+1))/2-2*m*((x*(x+1))/2);
10
+ }
11
+};
0 commit comments