Skip to content

Commit c0587d9

Browse files
sum to n
1 parent f069399 commit c0587d9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

maths/sum_to_n.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def sum_to_n(n: int) -> int:
2+
"""
3+
>>> sum_to_n(100)
4+
5050
5+
>>> sum_to_n(10)
6+
55
7+
"""
8+
return sum(i for i in range(1, n + 1))
9+
10+
11+
if __name__ == '__main__':
12+
from doctest import testmod
13+
14+
testmod()

0 commit comments

Comments
 (0)