You are on page 1of 1

public class GCD {

public static void main(String[] args) {


int n1 = 366, n2 = 60; || 1.
H.C.F(366,
60) (366, 60, 6) || 2.
H.C.F(60,6) (6, 0,)

int hcf = hcf(n1, n2);

System.out.printf("THE G.C.D of %d and %d is %d.", n1, n2, hcf); || Final


H.C.F(6,0) (6, 0, -)
}

public static int hcf(int n1, int n2) || n2 is


0.in the end the value of n1 is G.D.C or H.C.F of the given two numbers
{
if (n2 != 0)
return hcf(n2, n1 % n2); || No.
Recursive call n1 n2 n1%n2
else
return n1;
}
}

You might also like