From 53b7673b999cf24166f9a73a51cd2d6f8b6465de Mon Sep 17 00:00:00 2001 From: Siddhartha05 <114129547+Siddhartha05@users.noreply.github.com> Date: Thu, 20 Oct 2022 09:32:12 +0530 Subject: [PATCH] Create GP program java --- GP program java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 GP program java 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); + } +}