import java.util.*;
class HCF{
public static int determineHCF(int a, int b) {
if (b==0)
return a;
else
return determineHCF(b, a % b);
}
public static void main(String[] args)throws Exception {
HCF cal = new HCF();
Scanner input=new Scanner(System.in);
System.out.println("Enter first number: ");
int num1=input.nextInt();
System.out.println("Enter second number: ");
int num2=input.nextInt();
int hcf = cal.determineHCF(num1, num2);
System.out.println("HCF of two numbers= "+hcf);
}
}
|