Skip to content

Commit d28dbd5

Browse files
committed
Project Euler From Hackerrank - added
1 parent b1a9e71 commit d28dbd5

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)