Last active
September 4, 2018 18:23
-
-
Save martinr448/ebc3e81eb394eace14df0d0846b9e5d5 to your computer and use it in GitHub Desktop.
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
def sum_of_products(a, n): | |
running_totals = [0] * n | |
for x in a: | |
for i in range(n - 1): | |
running_totals[i] += running_totals[i + 1] * x | |
running_totals[-1] += x | |
return running_totals[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment