Skip to content

Instantly share code, notes, and snippets.

@codepainkiller
Created October 5, 2014 01:12
Show Gist options
  • Save codepainkiller/ed93e346d013894fe75b to your computer and use it in GitHub Desktop.
Save codepainkiller/ed93e346d013894fe75b to your computer and use it in GitHub Desktop.
Serie de fibonacci - C++
#include<iostream>
using namespace std;
int fibo(int n)
{
if(n == 0 || n == 1)
return n;
else
return fibo(n - 2) + fibo(n - 1);
}
int main()
{
cout<<"\n FIBONACCI \n\n";
int i, num ;
do
{
cout<<"Ingrese un numero entero y positivo: ";
cin>>num;
} while(num < 0);
cout<<"\nLa serie es: \n\n\t";
for(i=0; i<num; i++)
{
if(fibo(i) != 0)
cout<< ", ";
cout<< fibo(i);
}
system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment