Skip to content

Instantly share code, notes, and snippets.

@endolith
endolith / gcd_and_lcm.py
Last active October 19, 2025 14:42
GCD and LCM functions in Python for several numbers
# Greatest common divisor of 1 or more numbers.
from functools import reduce
def gcd(*numbers):
"""
Return the greatest common divisor of 1 or more integers
Examples
--------