Created
April 17, 2015 20:16
-
-
Save samir96/04179c2aef47db559101 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
//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