Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main() {
- int input, index=2;
- vector<int> fib;
- cout << "Enter a number" << endl;
- cin >> input;
- fib.push_back(0);
- fib.push_back(1);
- for (int counter = 0; counter < input; counter++) {
- fib.push_back(fib[index - 1] + fib[index - 2]);
- index++;
- }
- for (int counter = 0; counter < input; counter++) {
- cout << "fibonacci's [" << counter << "] number is " << fib[counter] << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement