Advertisement
Alx09

Untitled

Jun 20th, 2019
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. unsigned f1=1,f2=1,f3=1;
  7. unsigned long long n;
  8. int main()
  9. {
  10. cin>>n;
  11. n = n % 24;
  12. while(n > 2)
  13. {
  14. f3=f1+f2 ;
  15. if (f3 %9) f3 = f3 % 9;
  16. else f3 = 9;
  17. f1=f2;
  18. f2=f3;
  19.  
  20.  
  21. n--;
  22. }
  23. if (n == 0) cout << 9;
  24. else cout<<f3;
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement