Created
May 5, 2015 19:17
-
-
Save krysseltillada/fe655d33ee8a62fd6be5 to your computer and use it in GitHub Desktop.
fibonacci number generator
This file contains hidden or 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> | |
int main() | |
{ | |
int num1 = 1, num2 = 1, max_num = 0, sum = 0, counter = 0; | |
cout << "enter a number of values to generate a fibonacci numbers: "; | |
cin >> max_num; | |
cout << num1 << endl | |
<< num2 << endl; | |
while (counter < max_num){ | |
sum = num1 + num2; | |
cout << sum << endl; | |
num1 = sum; | |
counter++; | |
if (counter >= max_num){ | |
break; | |
} | |
sum = num1 + num2; | |
cout << sum << endl; | |
num2 = sum; | |
counter++; | |
} | |
system("pause"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment