Program to print GP ( Geometric Progression ) | Java program to print GP . ; function to print GP ; Driver code ; starting number ; Common ratio ; N th term to be find
class GFG { static void printGP ( int a , int r , int n ) { int curr_term ; for ( int i = 0 ; i < n ; i ++ ) { curr_term = a * ( int ) Math . pow ( r , i ) ; System . out . print ( curr_term + " ▁ " ) ; } } public static void main ( String [ ] args ) { int a = 2 ; int r = 3 ; int n = 5 ; printGP ( a , r , n ) ; } }