Produto acumulado
Crie uma função que receba um array e retorne um array com os produtos acumulados.
Exemplos
Program.accumulatingProduct(new int[]{1, 2, 3, 4}) ➞ new int[]{1, 2, 6, 24}
// A saída é [1, 1 × 2, 1 × 2 × 3, 1 × 2 × 3 × 4].
Program.accumulatingProduct(new int[]{1, 5, 7}) ➞ new int[]{1, 5, 35}
Program.accumulatingProduct(new int[]{1, 0, 1, 0}) ➞ new int[]{1, 0, 0, 0}
Program.accumulatingProduct(new int[0]) ➞ new int[0]Notas
- Um array vazio retorna um array vazio.