fork download
  1. from math import *
  2. prime = [1] * (10 ** 6 + 1 )
  3. def sang():
  4. prime[0] = 0
  5. prime[1] = 0
  6. for i in range(2 , isqrt((10 ** 6 + 1 )) + 1):
  7. if(prime[i]):
  8. for j in range(i * i , (10 ** 6 + 1 ), i):
  9. prime[j] = 0
  10.  
  11. if __name__ == '__main__':
  12. sang()
  13. F = [0] * (10 ** 6 + 1 )
  14. F[0] = 0
  15. F[1] = 0
  16. tich = 1
  17. for i in range(2 , (10 ** 6 + 1 )):
  18. if(prime[i]):
  19. tich *= i
  20. tich %= (10 ** 9 + 7)
  21. F[i] = tich
  22. F[i] %= (10 ** 9 + 7)
  23. t = int(input())
  24. for i in range(t):
  25. n = int(input())
  26. print(F[n])
  27.  
  28.  
Success #stdin #stdout 0.75s 56788KB
stdin
5
20
16
10
22
29
stdout
9699690
30030
210
9699690
469693188