Search This Blog

Wednesday 19 October 2016

TO FIND HIGHEST COMMON FACTOR OF TWO NUMBERS



public class hcf
{
    public static void hcf_lcm(int n,int m)
{
    int hcf,lcm,r,k=1;
    while(n>0)
    {
        r=m%n;
        if(r==0)
        {
           hcf=n;
         k=hcf;
        }   
      
       else
       {  n=m;
          n=r;
   
        }
      
  
   
  lcm=n*m/k;

  System.out.println("the hcf of no."+ k);

 System.out.println("the lcm of no."+ lcm);
}
}
}

No comments:

Post a Comment

Make a JAVA program for a Toystore. This program suggest the toy based on the inputs users gives like age , gender , etc

 //editor used - IntelliJ IDEA package ToyStore; import javax.swing.*; import java.awt.event.*; import java.util.Scanner; //here you can edi...