Advertisement
sheredega

task 11

Nov 4th, 2022
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     int temp = 0;
  9.     cin >> n;
  10.     int first = 0;
  11.     int second = 1;
  12.     cout << first << " ";
  13.     cout << second << " ";
  14.     while (temp <= n) {
  15.         temp = first;
  16.         first = second;
  17.         second = first + temp;
  18.         cout << second << " ";
  19.     }
  20.  
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement