File tree 1 file changed +8
-7
lines changed
1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change 7
7
8
8
"""
9
9
10
- def solution (n ,target ):
10
+
11
+ def solution (n , target ):
11
12
"""
12
13
Efficient Solution for Sum Multiple of 3 or 5
13
14
@@ -32,15 +33,15 @@ def solution(n,target):
32
33
"""
33
34
if target > 0 : # check for positive or negative
34
35
p = target // n
35
- return (n * ( p * ( p + 1 ))) // 2
36
+ return (n * ( p * ( p + 1 ))) // 2
36
37
else :
37
38
return 0
38
39
39
40
40
41
if __name__ == "__main__" :
41
42
N = int (input ())
42
- m = N - 1
43
- print (solution (3 ,m ) + solution (5 ,m ) - solution (15 ,m ))
44
-
45
- # For detail explanation of the above problem head to the below link:
46
- # https://github.com/BigOh-Koders/INCF2019/blob/master/MUL35/explanation.pdf
43
+ m = N - 1
44
+ print (solution (3 , m ) + solution (5 , m ) - solution (15 , m ))
45
+
46
+ # For detail explanation of the above problem head to the below link:
47
+ # https://github.com/BigOh-Koders/INCF2019/blob/master/MUL35/explanation.pdf
You can’t perform that action at this time.
0 commit comments