Skip to content

Latest commit

 

History

History

Multiply Array - GFG

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Multiply Array

Easy

Calculate the product of all the elements in an array.

Example 1:

Input:
5
1 2 3 4 5
Output:
120

 

Example 2:

Input:
10
5 5 5 5 5 5 5 5 5 5
Output:
9765625

 

Your Task:  
You don't need to read input or print anything. Your task is to complete the function product() which takes the array Arr[] and its size N as inputs and returns the product of all elements.


Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)

 

Constraints:
1  ≤  N  ≤  10
1  ≤  A[i]  ≤  5