Created
October 5, 2014 01:12
-
-
Save codepainkiller/ed93e346d013894fe75b to your computer and use it in GitHub Desktop.
Serie de fibonacci - C++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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