Dec 23, 2012 at 4:46pm
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);
}
}
Dec 24, 2012 at 2:56am
@Hamsterman : But I don't understand it.:(You can explain to me ???
I desperately needed.Thanks U :)
Dec 24, 2012 at 9:14am
Wait, that's working code... What do you mean by 'evaluate' ? to explain? Didn't you write it yourself?
Dec 24, 2012 at 10:11am
I want to analyze the running time of this algorithm.
Dec 24, 2012 at 10:14am
my english is not very good, can you not understand what I mean
Dec 24, 2012 at 10:49am
#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;
}