Write a program to find HCF of two number in java

 Write a program to find HCF of two number in java

public class HCF
{
    public static void main(String args[]){
    int number1=13,number2=117,hcf=1;
    for(int i=1; i<=number1 && i<=number2;i++){
        if(number1%i==0 && number2%i==0){
        hcf=i;
        }
    }
    System.out.println("HCF of "+number1+" and "+number2+" is "+hcf);
    }
}

Output
HCF of 13 and 117 is 13

Comments

Popular posts from this blog

Calculate Compound Interest in JavaScript

How to make simple bill maker by using python tkinter

Admin Login Page Using HTML and CSS