GCD of two numbers is the largest number that divides both of them. A simple way to find GCD is to factorize both numbers and multiply common factors.
GCD(10, 15) = 5 GCD(35, 10) = 5 GCD(31, 2) = 1
Time Complexity: O(Log min(a, b))
Please refer complete article on Basic and Extended Euclidean algorithms for more details!
Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.