MCPcopy Create free account
hub / github.com/Deepali-Srivastava/data-structures-and-algorithms-in-java / Euclids

Class Euclids

recursion/Euclids.java:8–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6import java.util.Scanner;
7
8public class Euclids
9{
10 private Euclids(){} //this class is not for instantiation
11
12 public static int GCD(int a, int b)
13 {
14 if(b==0)
15 return a;
16 return GCD(b, a%b);
17 }
18
19 public static void main(String[] args)
20 {
21 int a,b;
22 Scanner scan = new Scanner(System.in);
23 System.out.print("Enter values for a and b : ");
24 a = scan.nextInt();
25 b = scan.nextInt();
26 System.out.println("GCD of " + a + " and " + b + " is " + GCD(a,b));
27 scan.close();
28 }
29}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected