Advertisement
a53

Fibo_SC

a53
Sep 23rd, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. long long n;
  8. cin >> n;
  9.  
  10. n%=24; // pentru ca sirul se repeta din 24 in 24
  11.  
  12. int i=1;
  13. int j=1;
  14. for (int contor=3; contor<=n; contor++)
  15. {
  16. int k = i + j;
  17. i = j;
  18. j = k;
  19. }
  20. cout << (j % 9? j % 9 : 9);
  21.  
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement