Advertisement
nicuvlad76

Untitled

Nov 5th, 2022
661
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 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.   if(n==1) cout<<f1;
  11.   else
  12.   {
  13.       cout<<f1<<" "<<f2<<" ";
  14.       ///generam
  15.       for(i=3; i<=n;i++)
  16.       {
  17.           f=f1+f2;
  18.           cout<<f<<" ";
  19.           f1=f2;
  20.           f2=f;
  21.       }
  22.   }
  23.  
  24.  
  25.   return 0;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement