Java Program to Calculate HCF

Here is a simple java program to find highest common factor (HCF)…

class hcf
{
public static void main(int a,int b)
{
    int d;
    int v;
    int div;
    int divi;
    int rem;
    int r;
    int divisor=d;
    int divident=v;
    rem=v%d;
    while(rem=0)
    {
        divisor=rem;
        divident=d;
        rem=d%rem;
        r=rem;
    }
   System.out.println(“The HCF of “+a+” and “+b+” is “+r);
}
   
}

Add Comment