Cumulative Product
EasyData EngineeringArrayPrefix Sum
Description
Given an array of numbers, return the running product where each position holds the product of all values from the start up to and including that position.
Examples
Input:
[1,2,3,4]Output:
[1,2,6,24]Explanation:
Each position holds the product of every value from the start of the array through that point.
Input:
[2,0,5]Output:
[2,0,0]Explanation:
Each position holds the product of every value from the start of the array through that point.
Input:
[5]Output:
[5]Explanation:
Each position holds the product of every value from the start of the array through that point.
Constraints
- •
1 ≤ length ≤ 10³