Product of N terms of a given Geometric series | Function to calculate product of N terms of geometric series ; Find the product of first and the last term ; Return the sqrt of the above expression to find the product ; Given first term and common ratio ; Number of terms ; Function Call
function productOfGP ( a , r , n ) { let an = a * Math . pow ( r , n - 1 ) ; return Math . sqrt ( Math . pow ( a * an , n ) ) ; } let a = 1 , r = 2 ; let N = 4 ; document . write ( productOfGP ( a , r , N ) ) ;