Skip to content

Commit 2d3df78

Browse files
committed
Time - noniterative approach
1 parent f45f7e0 commit 2d3df78

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import time
2+
3+
4+
def sum_nums(n: int) -> int:
5+
start = time.time()
6+
total: int = n * (n + 1) / 2
7+
end = time.time()
8+
print("For ", n, " numbers time is", end - start)
9+
return total
10+
11+
12+
print(sum_nums(100))
13+
print(sum_nums(50000000))
14+

0 commit comments

Comments
 (0)