Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Time Complexity of Euclid's Algorithm

$
0
0
Hello everyone,

I have been given an assignment to code and then find the time complexity of Euclid's algorithm. The code is as follows:

int gcd(int m, int n) {
    int r;
    while (n != 0) {
        r = m % n;
        m = n;
        n = r;
    }
    return m;
}



I had no issues on that part. However, I have no idea how to go about finding the worst case and average case efficiencies.
I tried looking online for some information, but it is all flying over my head.

Hopefully someone here can help.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>