https://www.geeksforgeeks.org/time-complexity-of-euclidean-algorithm/- unsigned gcd_recursive(unsigned a, unsigned b)
- {
- if (b)
- return gcd_recursive(b, a % b);
- else
- return a;
- }
复制代码Let’s assume, the number of steps required to reduce b to 0 using this algorithm is N. gcd(a, b) ⟶ N steps Now, if the Euclidean Algorithm for two numbers a and b reduces in N steps then, a should be at least f(N + 2) and b should be at least f(N + 1). gcd(a, b) ⟶ N steps Then, a ≥ f(N + 2) and b ≥ f(N + 1) where, fN is the Nth term in the Fibonacci series(0, 1, 1, 2, 3, …) and N ≥ 0.
|