Last active
May 6, 2019 11:26
-
-
Save arifsuhan/655cd75b623e56cfb9fb15f8ff5f4399 to your computer and use it in GitHub Desktop.
Sum elements of nd-array (Python)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sum_without_loop(array, sum ): | |
if( type(array) == int or type(array) == float ): | |
sum += array | |
else: | |
for i in array: | |
sum = sum_without_loop(i,sum) | |
return sum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment