Skip to content

Instantly share code, notes, and snippets.

@alonzoibarra97
Created May 3, 2016 16:55
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 alonzoibarra97/ad83dffa86358b86943953e4a1c29cac to your computer and use it in GitHub Desktop.
Save alonzoibarra97/ad83dffa86358b86943953e4a1c29cac to your computer and use it in GitHub Desktop.
#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