HCF of two numbers
Write a program to find HCF of two numbers.
import java.util.*;
class L20HCFof2no
{
public static void main()
{
System.out.println("Enter two integers to calculate their Highest Common Factor");
Scanner in = new Scanner(System.in);
int x = in.nextInt();
int y = in.nextInt();
int l= Math.max(x,y);
int s= Math.min(x,y);
while(l%s!=0)
{
int temp=s;
s= l%s;
l=temp;
}
System.out.println("\n Highest Common Factor of given integers is "+s);
}
}
For Any Desired Program comment below. WE WILL TRY OUR BEST TO MAKE THAT PROGRAM AVAILABLE.
Please write a program of Integration of any variable no.
ReplyDelete