Page 1 of 1

Python: (Math) Greatest Common Factor of Counting Numbers

Posted: Mon Oct 20, 2025 9:01 pm
by Jason

Code: Select all

import math

the_first_number = 90

the_second_number = 30

GCF_of_the_two_numbers = math.gcd(the_first_number, the_second_number)

print(f"The GCF of {the_first_number} and {the_second_number} is {GCF_of_the_two_numbers}")
The GCF of Counting Numbers is found by dividing the target counting numbers respectively by counting numbers starting at 1, ignoring situations that don't divide evenly, looking at the highest match. It is useful for reducing the final answer of fraction problems.
What is the GCF of 10 and 20?
\(20: 20 \div 1 = 20 \,\,\,\, 20 \div 2 = \underline{10} \,\,\, 20 \div 4 = 5 \,\,\, 20 \div 5 = 4 \,\,\, 20 \div 10 = 2\)

\(30: 30 \div 1 = 30 \,\,\,\, 30 \div 2 = 15 \,\,\,\, 30 \div 3 = \underline{10} \,\,\,\, 30 \div 5 = 6\,\,\,\, 30 \div 6 = 5 \,\,\,\, 30 \div 10 = 3 \)

\(GCF = 10\)