Product of N terms of a given Geometric series | Java 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
class GFG { static float productOfGP ( float a , float r , int n ) { return ( float ) Math . pow ( a , n ) * ( float ) Math . pow ( r , n * ( n - 1 ) / 2 ) ; } public static void main ( String s [ ] ) { float a = 1 , r = 2 ; int N = 4 ; System . out . println ( productOfGP ( a , r , N ) ) ; } }