MohamedAbdel3al

Y. Easy Fibonacci

Sep 12th, 2021
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std ;
  4. #define sz(s) int(s.size())
  5. typedef long long ll ;
  6.  
  7. void ABDEL3AL () {
  8. ios_base::sync_with_stdio(false); cin.tie(nullptr) , cout.tie(nullptr) ;
  9. #ifndef ONLINE_JUDGE
  10. freopen("input.txt" , "r" , stdin) , freopen("output.txt" , "w" , stdout) ;
  11. #endif
  12. }
  13.  
  14.  
  15. int main() {
  16. ABDEL3AL() ;
  17. int n ; cin >> n ;
  18. int fib[n + 1] ;
  19. fib[1] = 0 , fib[2] = 1 ;
  20. for (int i = 3; i <= n; i++)
  21. fib[i] = fib[i - 1] + fib[i - 2] ;
  22. for (int i = 1; i <= n; i++)
  23. cout << fib[i] << " " ;
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment