fork(1) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void fib(unsigned long n)
  6. {
  7. unsigned long long a = 1, b = 1;
  8. for (unsigned long i = 1; i < n; i++) {
  9. b = a + b; //pod zmienną b przypisujemy wyraz następny czyli a+b
  10. a = b - a;
  11. b = b % 10000;
  12. a = a % 10000;
  13. }
  14. cout << a;
  15. }
  16.  
  17. int main()
  18. {
  19. unsigned long n;
  20. cin >> n;
  21. fib(n);
  22. return 0;
  23. }
Success #stdin #stdout 0s 15232KB
stdin
100
stdout
5075