From 4776d50390abf293b89ee480e0285c127391bc5f Mon Sep 17 00:00:00 2001 From: Arika Pandey <100206199+Arika008@users.noreply.github.com> Date: Thu, 13 Oct 2022 00:54:06 +0530 Subject: [PATCH] GCD GCD using java --- GCD | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 GCD diff --git a/GCD b/GCD new file mode 100644 index 0000000..56f0626 --- /dev/null +++ b/GCD @@ -0,0 +1,19 @@ + +// Java program to find GCD of two numbers +class Test +{ + // Recursive function to return gcd of a and b + static int gcd(int a, int b) + { + if (b == 0) + return a; + return gcd(b, a % b); + } + + // Driver method + public static void main(String[] args) + { + int a = 98, b = 56; + System.out.println("GCD of " + a +" and " + b + " is " + gcd(a, b)); + } +}