Kasus 5.8



INTERAKTIF

#include <iostream>

using namespace std;
int gcd(int c, int d)
{   int r;
    while (d > 0) {
            r = c % d; 
            c = d;
            d = r;  
    }
    return (c);
}

 

 

 


REDUKSI
#include <iostream>

using namespace std;
int gcd(int c, int d)
{  
    if (d==0) return(c);
    if (c<d) return(gcd(d,c));
    return(gcd(c-d, d));
}


Previous
Next Post »
Copyright © 2015 Bettong'rs All Right Reserved
Created by Arlina Design Powered by Blogger