hexor's blog

By hexor, 11 years ago, In English

What can I calculate N! for N<=10^9?

  • Vote: I like it
  • +5
  • Vote: I do not like it

»
11 years ago, # |
  Vote: I like it +6 Vote: I do not like it

Factorial grows exponentially, which means that 109! will have enormous amount of digits (linear of N, at least) and you won't be able to output or even store such big number.

  • »
    »
    11 years ago, # ^ |
      Vote: I like it +11 Vote: I do not like it

    I guess he meant to use modulo

    • »
      »
      »
      11 years ago, # ^ |
      Rev. 4   Vote: I like it +3 Vote: I do not like it

      even then, computing (for ) will result in TLE!
      unless he intends to use it to find (small , possibly big ), i don't think his problem is solvable.

»
11 years ago, # |
  Vote: I like it 0 Vote: I do not like it

If you want to get factorial by some modulo, you can do it in . Just precalc factorial in some checkpoints like , , , etc and then start calculating from the checkpoint.

»
11 years ago, # |
  Vote: I like it +8 Vote: I do not like it

Interesting how to find i-th number of (n!)?

»
11 years ago, # |
  Vote: I like it +6 Vote: I do not like it