Home /permanent

Euclidean Algorithm

An algorithm for finding the greatest common divisor of two integers.

The iterative algorithm represented in pseudocode like this:

function GreatestCommonDivisor(a, b)
    while a != b do
        if a > b then
            a = a - b
        else
            b = b - a
        end if
    end while

    return a

end function