Skip to content

Commit 24b5c71

Browse files
authored
O(1)
sum of all the numbers till n
1 parent daa539a commit 24b5c71

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

sum_total (∑n)

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def sum_total(n):
2+
return int(n*(n+1)/2)
3+
4+
5+
print(sum_total(10))

0 commit comments

Comments
 (0)