Skip to content

Instantly share code, notes, and snippets.

@oca159
Forked from codepainkiller/numeros_catalan.cpp
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oca159/6444621a262564ac7e1c to your computer and use it in GitHub Desktop.
Save oca159/6444621a262564ac7e1c to your computer and use it in GitHub Desktop.
#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