Find HCF or GCD of Two Numbers in Java
source link: https://www.geeksforgeeks.org/videos/find-hcf-or-gcd-of-2-numbers-in-java/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Find HCF or GCD of Two Numbers in Java
- 110 Views
- 15/07/2022
In this video, we will see Java Program to Find the HCF of 2 numbers.
The Highest Common Factor (HCF) is the greatest number that divides each of the two or more numbers. It is also known as Greatest Common Measure (GCM) and Greatest Common Divisor(GCD).
Properties of HCF:
1. Always an HCF of two or more prime numbers is 1.
2. The HCF of two or more numbers divides each of the numbers without a remainder.
3. The HCF of two or more numbers is a factor of each of the numbers.
4. The HCF of two or more numbers is less than or equal to each of the numbers always.
For example:
HCF of 18 21 30 is 3.
HCF of 5 and 25 is 5.
Here we see four different methodologies to find the HCF of 2 numbers:
1. Using the iterative method(while loop)
2. Using iterative efficient method(for loop)
3. Using the recursive method
4. Using the Euclidean formula
Find HCF or GCD of two numbers in Java: https://www.geeksforgeeks.org/java-program-to-find-gcd-or-hcf-of-two-numbers/
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK