fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int t, n;
  6. int factorial;
  7. scanf("%d", &t);
  8. while(t--)
  9. {
  10. scanf("%d", &n);
  11. if(n <= 4)
  12. {
  13. factorial = 1;
  14. for(int i = 1; i <= n; ++i)
  15. factorial *= i;
  16. printf("%d\n", factorial);
  17. }
  18.  
  19. else
  20. printf("0\n");
  21. }
  22. return 0;
  23. }
Success #stdin #stdout 0s 4516KB
stdin
11
0
1
2
3
4
5
6
7
8
9
10
stdout
1
1
2
6
24
0
0
0
0
0
0