fork download
  1. # source: http://stackoverflow.com/a/14759302
  2. def cum_fact(arr):
  3. cumulative_sum = 0
  4. latest_factorial = 1
  5. for a in arr:
  6. latest_factorial *= a
  7. cumulative_sum += latest_factorial
  8. return cumulative_sum
  9.  
  10. nums = [5, 3, 7]
  11. print(cum_fact(nums))
Success #stdin #stdout 0.02s 9984KB
stdin
Standard input is empty
stdout
125