fork download
  1. #include <bits/stdc++.h>
  2. #define m 1000000007
  3. using namespace std;
  4.  
  5. int main() {
  6. // your code goes here
  7. long long int t;
  8. cin>>t;
  9. while(t--){
  10. long long int n;cin>>n;
  11. if(n==0 || n==1)cout<<1<<"\n";
  12. else{
  13. long long int fact=1;
  14. for(int i=1;i<=n;i++){
  15. fact=(fact*i)%m;
  16. }
  17. cout<<fact<<"\n";
  18. }
  19. }
  20. return 0;
  21. }
Success #stdin #stdout 0s 5268KB
stdin
3
5
20
50
stdout
120
146326063
318608048