Solution Review: Greatest Common Divisor

This lesson will explain how to use the math module to find the greatest common divisor.

We'll cover the following

Solution: Import built-in Math Module

  • Import the math library using import math

  • Use the built-in function math.gcd(number1,number2) function to return the greatest common divisors of two numbers

The following python code demonstrates how to find the gcd of a number using the built-in math module:

Get hands-on with 1000+ tech skills courses.