My issue
help me understand the below solution for Fibonacci Series.
My code
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int last = 1;
int second_last = 0;
cout << 0 << " " << 1 << " ";
for(int i = 3; i <= n; i++) {
int temp = last;
last = last + second_last;
second_last = temp;
cout << last << " ";
}
return 0;
}
Learning course: Complete C++ course
Problem Link: Coding problem - 2 Practice Problem in Complete C++ course - CodeChef