Sum of Arithmetic Geometric Sequence | Return the sum of first n term of AGP ; finding the each term of AGP and adding it to sum . ; Driver Code
function sumofNterm ( a , d , b , r , n ) { let sum = 0 ; for ( let i = 1 ; i <= n ; i ++ ) sum += ( ( a + ( i - 1 ) * d ) * ( b * Math . pow ( r , i - 1 ) ) ) ; return sum ; } let a = 1 ; let d = 1 ; let b = 2 ; let r = 2 ; let n = 3 ; document . write ( sumofNterm ( a , d , b , r , n ) ) ;