Over a million developers have joined DZone.

Euclid's Algorithm

DZone's Guide to

Euclid's Algorithm

Free Resource
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

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}