Please help me evaluation this algorithm.Thanks very much @@
the greatest common divisor
int UCLN(int n,int m)
{
if(n%m==0) return m;
else {
int k=n%m;
return UCLN(m,k);
}
}
@Hamsterman : But I don't understand it.:(You can explain to me ???
I desperately needed.Thanks U :)
Wait, that's working code... What do you mean by 'evaluate' ? to explain? Didn't you write it yourself?
I want to analyze the running time of this algorithm.
my english is not very good, can you not understand what I mean
#include <cstdlib>
#include <iostream>
using namespace std;
int UCLN(int n,int m) {
cout << endl << "MCD of " << n << " and " << m;
if(n%m==0) {
cout << endl << "found MCD: " << m;
return m;
}
else {
int k=n%m;
cout << endl << "remainder " << n << "/" << m << ": " << k;
return UCLN(m,k);
}
}
int main(int argc, char *argv[])
{
cout << endl << UCLN(1071, 462);
system("PAUSE");
return EXIT_SUCCESS;
}