Created
November 16, 2014 20:20
-
-
Save TheSecretSquad/963df5b3e9b9420ede31 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; | |
int main () | |
{ | |
unsigned long previousNthFibNumber = 0, | |
nthFibNumber = 1, | |
sum = 0, | |
numEntered; | |
std::cout << "Enter a number to count to using a Fibonacci Sequence: "; | |
std::cin >> numEntered; | |
for (sum; sum < numEntered; sum = previousNthFibNumber + nthFibNumber) | |
{ | |
cout << sum << endl; | |
previousNthFibNumber = nthFibNumber; | |
nthFibNumber = sum; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment