[ create a new paste ] login | about

Link: http://codepad.org/LYD83gSN    [ raw code | output | fork ]

salvador@conclase.net - C++, pasted on Nov 13:
// Algoritmo de Euclides
// (C) 2009 Con Clase
// Salvador Pozo

#include <iostream>
using namespace std;

int mcd(int, int);

int main() {
    int a, b;

    a = 364332;
    b = 30252;

    cout << "mcd(" << a << ", " << b << ")= " << mcd(a,b) << endl;
    return 0;
}

int mcd(int a, int b) {
    if(a < b) return mcd(b,a);
    if(b==0) return a;
    return mcd(b, a % b);
}


Output:
1
mcd(364332, 30252)= 12


Create a new paste based on this one


Comments: