#include <iostream> using namespace std; // Fibonacci sequence int main() { int first = 0, second = 1; int next, num; cout << "Enter the number of Fibonacci sequence" << endl; cin >> num; cout << "Fibonacci series is " << endl; for (int i = 1; i <= num; ++i) { cout << first << endl; next = first + second; first = second; second = next; } return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter