Skip to content

Commit 4c6121d

Browse files
committed
Add a_very_big_sum algorithm to maths folder
1 parent e2a78d4 commit 4c6121d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from typing import List
2+
3+
def a_very_big_sum(arr: List[int]) -> int:
4+
"""
5+
Return the sum of all integers in the input array.
6+
7+
>>> a_very_big_sum([2, 4, 6, 2, 4, 6, 3])
8+
27
9+
>>> a_very_big_sum([])
10+
0
11+
>>> a_very_big_sum([1000000000, 2000000000])
12+
3000000000
13+
"""
14+
if not all(isinstance(x, int) for x in arr):
15+
raise ValueError("All elements in the array must be integers")
16+
17+
total = 0
18+
for number in arr:
19+
total += number
20+
return total

0 commit comments

Comments
 (0)