Created
April 17, 2015 20:45
-
-
Save fernandoalv/c9af0b0cf2fa288f64c8 to your computer and use it in GitHub Desktop.
This file contains 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; | |
long long Fib(long x){ | |
long a=0, b=1, c=a+b; | |
if(x==0) return 0; | |
if(x==1) return 1; | |
if(x>=3){ | |
for(long i=3;i<=x;i++){ | |
a=b; | |
b=c; | |
c=a+b; } | |
return c; | |
} | |
} | |
int main() | |
{ | |
long y,t; | |
cout<<"Dame un numero; "; | |
cin>>y; | |
t=Fib(y); | |
cout<<"El fibbonaci del numero es " << t <<endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment