Program to calculate HCF and LCM (java).


This program is helpful for all computer students.

//Created and posted by Subrata Sir(HOD,East West Model School)
//Website:-subrataray.hpage.com
class number
{
int hcf,lcm,p;
public void display(int a,int b)
{
p=a*b;
for(int i=1;i<=p;i++)
{
if(a%i==0)
{
hcf=i;
}
}
lcm=p/hcf;
System.out.println("hcf="+hcf);
System.out.println("lcm="+lcm);
}
}


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: