Skip to content

Instantly share code, notes, and snippets.

@DiegoNaterasPonce
Created April 19, 2016 16:09
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 DiegoNaterasPonce/a7e4ac4f8542c820c90ba45504a36aa1 to your computer and use it in GitHub Desktop.
Save DiegoNaterasPonce/a7e4ac4f8542c820c90ba45504a36aa1 to your computer and use it in GitHub Desktop.
#WSQ13 Exam2 Prog3
#include <iostream>
#include <iomanip>
using namespace std;
int x, y, n1 = 0, n2 = 1;
int fibonacci(int x){
for (int t = 1; t < x ; t++){
y = n1 + n2;
n1 = n2;
n2 = y;
}
return y;
}
int main(){
cout << "We are going to print the number in the fibonacci sequence you tell me \n";
cout << "Tell me a number: \n";
cin >> x;
cout << "The number in the fibonacci sequence is: " <<fibonacci(x)<<endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment