Created
April 19, 2016 16:09
-
-
Save DiegoNaterasPonce/a7e4ac4f8542c820c90ba45504a36aa1 to your computer and use it in GitHub Desktop.
#WSQ13 Exam2 Prog3
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> | |
#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