fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int fact(int m){
  5. if(m==0 || m==1){
  6. return 1;
  7. }
  8. else return m*fact(m-1);
  9. }
  10. int main() {
  11. // your code goes here
  12. int t;
  13. cin>>t;
  14. for(int i=0;i<t;i++){
  15. int n;
  16. cin>>n;
  17. cout<<fact(n);
  18. }
  19. return 0;
  20. }
Success #stdin #stdout 0s 15232KB
stdin
1
3
stdout
6