What is the time complexity of __gcd(m,n) function? Also, does it use the Euclidean method to calculate gcd?
e.g. code
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
cout << "gcd(10, 25) : " << __gcd(6, 20) << endl;
}
Yes, it use Euclidean method to calculate gcd of two values. It's complexity is 𝑂(𝑙𝑜𝑔2𝑛) algorithm, where n is the upper limit of a and b.
Details : https://www.quora.com/What-is-the-time-complexity-of-Euclids-GCD-algorithm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With