Problems > Reduce the Fraction > Editorial

Reduce the Fraction — Solution & Editorial

Back to the Problem

Divide both parts by gcd(A, B) (Euclid's algorithm).

Complexity: O(log min(A, B))