diff --git a/2894. Divisible and Non-divisible Sums Difference b/2894. Divisible and Non-divisible Sums Difference new file mode 100644 index 0000000..5bf310e --- /dev/null +++ b/2894. Divisible and Non-divisible Sums Difference @@ -0,0 +1,11 @@ +class Solution { +public: + int differenceOfSums(int n, int m) { + // we need to find S(n)-2*(divisibles) + + // no of divisibles + int x=n/m; + + return (n*(n+1))/2-2*m*((x*(x+1))/2); + } +};