Over a million developers have joined DZone.

Euclid's Algorithm

·
Euclid(a, b) calculates the largest common denominator d, and returns it.

Uses the well-known Euclid's algorithm.


def euclid(a, b):
  while b != 0:
    r = a % b
    a = b
    b = r
  return a
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}