Skip to content

Instantly share code, notes, and snippets.

@ttowncompiled
Last active June 14, 2018 14:58
Show Gist options
  • Save ttowncompiled/34dbad3902368be32dcdcc25b8fa25cd to your computer and use it in GitHub Desktop.
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.
# 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