Multiply the Whole List
A product is useful when values should build on each other through multiplication instead of simple addition. Write grow, which takes a non-empty list of numbers arr and returns the result of multiplying all its elements. Start with the first number and multiply it by each of the remaining numbers in order.
Примеры
Ввод
[1, 2, 3]Вывод
6Ввод
[4, 1, 1, 1, 4]Вывод
16Ввод
[2, 2, 2, 2, 2]Вывод
32Нужно реализовать
def grow(arr: list[int]) -> int:
Теги
listsarraymath
Pieslēdzies, lai redzētu iesniegumu vēsturi
PieslēgtiesPieslēdzies, lai izmantotu AI mentoru
PieslēgtiesVisible tests
1
Input
[1,2,3]Expected
62
Input
[4,1,1,1,4]Expected
163
Input
[2,2,2,2,2]Expected
324
Input
[5]Expected
55
Input
[1,1,1]Expected
16
Input
[1,1,1,1,1]Expected
1Focus radio
Paused · SomaFM · Fluid