nicuvlad76

Untitled

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