GCD of two numbers

Problem Statement

Intuition

Appraoch:

GCD (a,b) = GCd(a-b, b) = Gcd(a%b, b) where a>b
The moment we get one of zero we return other


Time Comp = O(logbase(phi){min(a,b)})

https://www.youtube.com/watch?v=1xNbjMdbjug&ab_channel=takeUforward

Approach 1:

C++

Approach 2:

C++

Approach 3:

C++

Approach 4:

C++

Similar Problems

Last updated