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
GCD of two numbers O(log(max(a,b)))
#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