ValerianBenchea

Sirul lui Fibonacci

Nov 26th, 2019
280
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.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     unsigned long long f1=1, f2=1, term, n, i;
  8.     cout<<"n="; cin>>n;
  9.     cout<<f1<<" "<<f2<<" ";
  10.     for(i=3; i<=n; i++)
  11.     {
  12.         term=f1+f2;
  13.         cout<<term<<" ";
  14.         f1=f2;
  15.         f2=term;
  16.     }
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment