write a program to find HCF of two numbers in Java using while loop
Answers
Answered by
9
⭐hey there!!
To find the HCF of tho numbers using while loop:
=>
public class GCD {
public static void main(String[] args) {
int n1 = 81, n2 = 153;
while(n1 != n2)
{
if(n1 > n2)
n1 -= n2;
else
n2 -= n1;
}
System.out.println("G.C.D = " + n1);
}
}
______________________________________
⭐Hope it will help u
To find the HCF of tho numbers using while loop:
=>
public class GCD {
public static void main(String[] args) {
int n1 = 81, n2 = 153;
while(n1 != n2)
{
if(n1 > n2)
n1 -= n2;
else
n2 -= n1;
}
System.out.println("G.C.D = " + n1);
}
}
______________________________________
⭐Hope it will help u
nike14:
thanku
Similar questions