Given two integer x and y, the task is to find the HCF of the numbers without using recursion or Euclidean method.
Input: x = 16, y = 32
Input: x = 12, y = 15
Approach: HCF of two numbers is the greatest number which can divide both the numbers. If the smaller of the two numbers can divide the larger number then the HCF is the smaller number. Else starting from (smaller / 2) to 1 check whether the current element divides both the numbers . If yes, then it is the required HCF.
Below is the implementation of the above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Program to find GCD or HCF of two numbers using Middle School Procedure
- Program to find GCD or HCF of two numbers
- Program to find HCF (Highest Common Factor) of 2 Numbers
- Decimal to Binary using recursion and without using power operator
- Euclidean algorithms (Basic and Extended)
- C Program for Basic Euclidean algorithms
- Java Program for Basic Euclidean algorithms
- Pairs with same Manhattan and Euclidean distance
- Minimum Sum of Euclidean Distances to all given Points
- Calculate the Square of Euclidean Distance Traveled based on given conditions
- QA - Placement Quizzes | Numbers, LCM and HCF | Question 15
- HCF of array of fractions (or rational numbers)
- Program to find HCF iteratively
- Find the other number when LCM and HCF given
- To find sum of two numbers without using any operator
- QA - Placement Quizzes | HCF | Question 2
- QA - Placement Quizzes | HCF | Question 3
- QA - Placement Quizzes | HCF | Question 4
- QA - Placement Quizzes | HCF | Question 5
- QA - Placement Quizzes | HCF | Question 6
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.