Product of N terms of a given Geometric series | Function to calculate product of geometric series ; Initialise final product with 1 ; Multiply product with each term stored in a ; Return the final product ; Given first term and common ratio ; Number of terms ; Function Call
function productOfGP ( a , r , n ) { let product = 1 ; for ( let i = 0 ; i < n ; i ++ ) { product = product * a ; a = a * r ; } return product ; } let a = 1 , r = 2 ; let N = 4 ; document . write ( productOfGP ( a , r , N ) ) ;