fork(2) download
  1. #include <stdio.h>
  2.  
  3. unsigned long int fat(unsigned int n) {
  4. int fatorial = 1;
  5. for (int i = 1; i <= n; i++) fatorial *= i;
  6. return fatorial;
  7. }
  8.  
  9. int main() {
  10. int numero;
  11. scanf("%d", &numero);
  12. printf("%d! = %ld", numero, fat(numero));
  13. }
  14.  
  15. //https://pt.stackoverflow.com/q/330965/101
Success #stdin #stdout 0s 9424KB
stdin
10
stdout
10! =  3628800