Skip to content

Instantly share code, notes, and snippets.

@codepainkiller
Created October 5, 2014 02:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save codepainkiller/efdb344e792eeaeac700 to your computer and use it in GitHub Desktop.
Save codepainkiller/efdb344e792eeaeac700 to your computer and use it in GitHub Desktop.
Números de Catalan - C++
#include <iostream>
#include <cstdlib>
using namespace std;
int Catalan(int n)
{
if (n <= 0)
return 1;
else
return (2 * (2*n - 1) * Catalan(n - 1)) / (n + 1);
}
int main()
{
cout << "\n Numeros de catalan \n\n";
int n ;
cout << "Ingrese numero: ";
cin >> n;
cout << endl << endl;
for(int i=0; i<n; i++)
{
cout << Catalan(i);
cout <<", ";
}
system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment