Python: (Math) Greatest Common Factor of Counting Numbers

Post Reply
User avatar
Jason
Site Admin
Posts: 853
Joined: Tue Jul 01, 2025 10:13 am

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\)
 

POSTREACT(ions) SUMMARY

Post Reply