Skip to content

Instantly share code, notes, and snippets.

@samir96
Created April 17, 2015 20:16
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 samir96/04179c2aef47db559101 to your computer and use it in GitHub Desktop.
Save samir96/04179c2aef47db559101 to your computer and use it in GitHub Desktop.
//Jorge Samir Godinez Lara/ A01630155
#include <iostream>
using namespace std;
long long Fibonacci(long n){
long a=0, b=1, c=a+b;
if(n==0) return 0;
if(n==1) return 1;
if(n>=3){
for(long i=3;i<=n;i++){
a=b;
b=c;
c=a+b; }
return c;
}
}
int main(){
long num;
cout<<"give me a number: ";
cin>>num;
cout<<"Fibonacci of you number is: " <<Fibonacci(num)<<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment