fork download
  1. #include <stdio.h>
  2.  
  3. void factorial_divide_et_impera(int lo, int hi, int* res) {
  4.  
  5. int a, b;
  6.  
  7. if(lo == hi) *res = lo;
  8. else {
  9. int m = (lo + hi) >> 1;
  10. factorial_divide_et_impera(lo, m, &a);
  11. factorial_divide_et_impera(m + 1, hi, &b);
  12. *res = a * b;
  13. }
  14. }
  15.  
  16. int main(int argc, char const *argv[]) {
  17.  
  18. int n, res;
  19.  
  20. scanf("%d", &n);
  21. factorial_divide_et_impera(1, n, &res);
  22. printf("%d\n", res);
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 5640KB
stdin
10
stdout
3628800