Fast Factorial Calculator 2

View as PDF

Submit solution

Points: 25 (partial)
Time limit: 0.6s
Memory limit: 64M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

d is not in a good mood today, so he has decided to torment people. He wants you to write a large factorial calculator. More specifically, he wants you to calculate very very very large factorials. He wishes you luck.

Input Specification

The first line of input contains the integer N, 0 \le N \le 1\,000, the number of cases to follow.

The next N lines will contain an integer n, such that 0 \le n \le 2^{63}, whose factorial you are to calculate.

Output Specification

For every integer n, you are to output n! \pmod{2^{32}-5}.

Sample Input

2
5
13

Sample Output

120
1932053509

Comments


  • -17
    Beautiful_Times  commented on Nov. 12, 2017, 2:33 p.m.

    This comment is hidden due to too much negative feedback. Click here to view it.


    • 22
      BonyBen  commented on Nov. 13, 2017, 1:20 a.m.

      No


  • 33
    moladan123  commented on Nov. 2, 2016, 3:11 p.m.

    Good job d, you just turned a comment into a problem ;)


  • -5
    elm224  commented on Nov. 2, 2016, 12:11 a.m.

    This comment is hidden due to too much negative feedback. Click here to view it.


    • 7
      nathanl3  commented on Nov. 2, 2016, 7:47 a.m.

      For every integer n, you are to output n! (mod 2^{32}-5)