diff --git a/GP program java b/GP program java new file mode 100644 index 0000000..291584b --- /dev/null +++ b/GP program java @@ -0,0 +1,19 @@ +class GP { + 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 + " "); + } + } + + // Driver code + public static void main(String[] args) + { + int a = 2; // starting number + int r = 3; // Common ratio + int n = 5; // N th term to be find + printGP(a, r, n); + } +}