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
< ? php function sumofNterm ( $ a , $ d , $ b , $ r , $ n ) { $ sum = 0 ; for ( $ i = 1 ; $ i <= $ n ; $ i ++ ) $ sum += ( ( $ a + ( $ i - 1 ) * $ d ) * ( $ b * pow ( $ r , $ i - 1 ) ) ) ; return $ sum ; } $ a = 1 ; $ d = 1 ; $ b = 2 ; $ r = 2 ; $ n = 3 ; echo ( sumofNterm ( $ a , $ d , $ b , $ r , $ n ) ) ; ? >