HCF (Highest Common Factor) or GCD (Greatest Common Divisor) of two numbers is the largest number that divides both of them.
For example GCD of 20 and 28 is 4 and GCD of 98 and 56 is 14.
We have discussed recursive solution in below post.Recursive program to find GCD or HCF of two numbers
Below is iterative implementation of Euclid’s algorithm
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 value of 1^k + 2^k + 3^k + ... + n^k
- Program to find sum of 1 + x/2! + x^2/3! +...+x^n/(n+1)!
- Program to find GCD or HCF of two numbers
- Program to find LCM of two numbers
- Program to find sum of the given sequence
- Program to find sum of series 1 + 1/2 + 1/3 + 1/4 + .. + 1/n
- Program to find the sum of the series (1/a + 2/a^2 + 3/a^3 + ... + n/a^n)
- Program to Find the value of cos(nΘ)
- Program to find the value of tan(nΘ)
- Program to find the sum of a Series 1 + 1/2^2 + 1/3^3 + …..+ 1/n^n
- Program to find sum of series 1 + 2 + 2 + 3 + 3 + 3 + . . . + n
- Program to find the value of sin(nΘ)
- Program to find sum of series 1*2*3 + 2*3*4+ 3*4*5 + . . . + n*(n+1)*(n+2)
- Program to find the sum of a Series (1*1) + (2*2) + (3*3) + (4*4) + (5*5) + ... + (n*n)
- Program to find Sum of the series 1*3 + 3*5 + ....
- Program to find greater value between a^n and b^n
- Program to find LCM of 2 numbers without using GCD
- Program to find the sum of the series 1 + x + x^2+ x^3+ .. + x^n
- Program to find last two digits of 2^n
- Program to find Sum of a Series a^1/1! + a^2/2! + a^3/3! + a^4/4! +…….+ a^n/n!
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.