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 62d53a4 commit 2600629Copy full SHA for 2600629
leetcode/daily/2894/sol.go
@@ -0,0 +1,24 @@
1
+// https://leetcode.com/problems/divisible-and-non-divisible-sums-difference
2
+
3
+package main
4
5
+import "fmt"
6
7
+func differenceOfSums(n int, m int) int {
8
+ sum1 := 0
9
+ sum2 := 0
10
11
+ for i := 1; i <= n; i++ {
12
+ if i%m == 0 {
13
+ sum2 += i
14
+ } else {
15
+ sum1 += i
16
+ }
17
18
19
+ return sum1 - sum2
20
+}
21
22
+func main() {
23
+ fmt.Println(differenceOfSums(10, 3))
24
leetcode/daily/2894/sol.py
@@ -0,0 +1,14 @@
+# https://leetcode.com/problems/divisible-and-non-divisible-sums-difference
+class Solution:
+ def differenceOfSums(self, n: int, m: int) -> int:
+ sum1 = 0
+ sum2 = 0
+ for i in range (1, n + 1):
+ if i % m == 0:
+ else:
0 commit comments