Skip to content

Instantly share code, notes, and snippets.

@fernandoalv
Created April 17, 2015 20:45
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 fernandoalv/c9af0b0cf2fa288f64c8 to your computer and use it in GitHub Desktop.
Save fernandoalv/c9af0b0cf2fa288f64c8 to your computer and use it in GitHub Desktop.
#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