Recursion Flashcards

1
Q

GCD of two numbers O(log(max(a,b)))

A
#include 
using namespace std;
int gcd(int a,int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
int main()
{
    int a=6,b=16;
    int x=gcd(a,b);
    cout
How well did you know this?
1
Not at all
2
3
4
5
Perfectly