Gcd
Euclidean algorithm
Recursive:
Iterative:
C++ Built-in function
C++ has a built-in __gcd
function.
Since C++11, we can directly use gcd
.
Time Complexity
https://www.geeksforgeeks.org/time-complexity-of-euclidean-algorithm/
It's O(log(min(A, B)))
Problems
Last updated