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 03297c8 commit 8d89e6dCopy full SHA for 8d89e6d
Project-Euler(Hackerrank)/ProjectEuler1-Multiples-of-3-and-5.py
@@ -0,0 +1,19 @@
1
+# Author : Junth Basnet
2
+"""
3
+https://www.hackerrank.com/contests/projecteuler/challenges/euler001/problem
4
5
+def S(n):
6
+ return (n * (n + 1)) // 2
7
+
8
+for _ in range(int(input())):
9
10
+ n = int(input())
11
+ #Sum of natural numbers below the given number
12
+ n -= 1
13
14
+ result = (S(n // 3) * 3) + (S(n // 5) * 5) - (S(n // 15) * 15)
15
+ print(result)
16
17
18
19
0 commit comments