Finding H.C.F. - G.C.D. in Python
A common method for finding H.C.F. - G.C.D. is repeated factorization
using only common factors.
If we have the set of numbers 30, 48 and
54 for example, their H.C.F. or G.C.D. is found thus:
Hence, H.C.F. of 30, 48 and 54 = 2 X 3 = 6
Simulating H.C.F. (G.C.D.) in Python code
We shall follow the steps below in writing our code.
Step 1:
Do a numerical sort on the set so its first member
is the smallest in the set.
Step 2:
Starting with 2, iteratively check through the set
of numbers for a common factor.
Step 3:
For each common factor, divide every member of the number
set by the common factor.
Step 4:
Repeat from step 2 recursively until there are no more
common factors.
Create a new module file; File, New File.
Call it FindHCF.py
Type out the adjoining Python code for finding Highest Common Factor (Greatest Common Divisor).(H.C.F.)