Advertisement
STANAANDREY

fact sda

Nov 10th, 2023 (edited)
1,182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. typedef unsigned long long ull;
  4.  
  5. ull fact(ull x) {
  6.     if (x == 0) {
  7.         return 1;
  8.     }
  9.     ull ans = 1;
  10.     for (ull i = 2; i <= x; i++) {
  11.         ans *= i;
  12.     }
  13.     return ans;
  14. }
  15.  
  16. int main(void) {
  17.     ull x;
  18.     scanf_s("%llu", &x);
  19.     printf("%llu", fact(x));
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement