Created
May 3, 2016 16:55
-
-
Save alonzoibarra97/ad83dffa86358b86943953e4a1c29cac 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 fibonacci (long num1){ | |
int a,b=0,c=1; | |
for(int i=1; i<num1; i++){ | |
a=b+c; | |
b=c; | |
c=a; | |
} | |
return a; | |
} | |
int main(){ | |
int n,fib; | |
cout<<"Give me the number you want to calculate its fibonacci"<<endl; | |
cin>>n; | |
fib= fibonacci(n); | |
cout<<fib; | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment