HCF of two Numbers | Python Program

Python Program to find HCF

Given two positive integers A and B, find GCD of A and B.

The HCF is a mathematical term for the Highest Common Divisor of two or more numbers. It is the Highest common divisor that completely divides two or more numbers without leaving any remainder. Therefore, it is also known as the Greatest Common Factor (GCD) of two numbers.

For example, the GCD of two numbers, 20 and 28, is 4 because both 20 and 28 are completely divisible by 1, 2, 4 (the remainder is 0), and the largest positive number among the factors 1, 2, and 4 is 4. Similarly, the GCD of two numbers, 24 and 60, is 12.

Example 1:

Input: A = 3, B = 6
Output: 3
Explanation: GCD of 3 and 6 is 3

Example 2:

Input: A = 1, B = 1
Output: 1
Explanation: GCD of 1 and 1 is 1
HCF Solution
Previous
Previous

Broaden your Chess Knowledge

Next
Next

LCM of two Numbers | Python Programming