Last active
June 14, 2018 14:58
-
-
Save ttowncompiled/34dbad3902368be32dcdcc25b8fa25cd to your computer and use it in GitHub Desktop.
Computes the product of the elements of A. complexity: O(n), where n is the number of elements in A.
This file contains 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
# python 3.6.5 | |
# from typing import List | |
def prod( A: List[int] ) -> int: | |
""" Computes the product of the elements of A. """ | |
if A == None or len(A) == 0: | |
return 0 | |
z: int = 1 | |
for a in A: | |
z *= a | |
return z |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment