Product of N terms of a given Geometric series | C ++ program for the above approach ; Function to calculate product of geometric series ; Return the final product with the above formula ; Driver Code ; Given first term and common ratio ; Number of terms ; Function Call
#include <bits/stdc++.h> NEW_LINE using namespace std ; float productOfGP ( float a , float r , int n ) { return pow ( a , n ) * pow ( r , n * ( n - 1 ) / 2 ) ; } int main ( ) { float a = 1 , r = 2 ; int N = 4 ; cout << productOfGP ( a , r , N ) ; }