Computer Science, asked by nike14, 1 year ago

write a program to find HCF of two numbers in Java using while loop

Answers

Answered by aman1091
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

nike14: thanku
nike14: give me some tips to study
nike14: write a program in Java to find the LCM of two numbers
nike14: ok
nike14: Plz answer I have ask this question
Similar questions