[ create a new paste ] login | about

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

C++, pasted on Feb 5:
#include <iostream>

using namespace std;

int fibonacci(int x)
{
	if (x == 0)
	return 0;
	if (x == 1)
	return 1;
	return fibonacci(x-1) + fibonacci(x-2);
}

int cmmdc(int a, int b)
{
	if ( (!a) || (!b) ) return a+b;
	if ( a>b ) return cmmdc(a%b, b);
	return cmmdc(a, b%a);
}

int main()
{
	int m=5, n=7;

	int x=fibonacci(m);
	int y=fibonacci(n);

	cout << cmmdc(x, y);

	return 0;
}


Output:
1
1


Create a new paste based on this one


Comments: