## FACTMUL - Product of factorials

no tags

You need to find the product of first n factorials 1! * 2! * ... * n! modulo 109546051211.

### Input

One integer n (1 <= n <= 10000000)

### Example

```Input:
5

Output:
34560```

## Code Examples

### #1 Code Example with Python Programming

```Code - Python Programming```

``````N = int(input())
p = 1
fac = 1
for i in range(1, N + 1):
fac = fac * i % 109546051211
p = p * fac % 109546051211
if p == 0:
break
print(p)``````
Copy The Code &

Input

cmd
5

Output

cmd
34560

### #2 Code Example with Java Programming

```Code - Java Programming```

``````import java.io.*;
import java.util.*;

class A{
public static void main(String[] args) {
final OutputWriter out = new OutputWriter(System.out);
Solver sol = new Solver();
//		while(t-- > 0){
sol.solve(in, out);
//		}
out.flush();
out.close();
}
}
class Solver{

long fact = (long)1;
String input = "109546051211";
long mod = Long.parseLong(input);
long pro = (long)1;
for(int i = 2;i <= n; i++){
fact = (fact *i) % mod;
pro = ((pro)* (fact))%mod;
}
out.printLine(pro);
}
}
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private SpaceCharFilter filter;

{
this.stream = stream;
}

{
if (numChars == -1)
throw new InputMismatchException();
if (curChar >= numChars)

{
curChar = 0;
try
{
} catch (IOException e)
{
throw new InputMismatchException();
}
if (numChars <= 0)
return -1;
}
return buf[curChar++];
}

{
while (isSpaceChar(c))
int sgn = 1;
if (c == '-')
{
sgn = -1;
}
int res = 0;
do
{
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
} while (!isSpaceChar(c));
return res * sgn;
}

{
while (isSpaceChar(c))
StringBuilder res = new StringBuilder();
do
{
res.appendCodePoint(c);
} while (!isSpaceChar(c));
return res.toString();
}
while (isSpaceChar(c))
int sgn = 1;
if (c == '-') {
sgn = -1;
}
double res = 0;
while (!isSpaceChar(c) && c != '.') {
if (c == 'e' || c == 'E')
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
}
if (c == '.') {
double m = 1;
while (!isSpaceChar(c)) {
if (c == 'e' || c == 'E')
if (c < '0' || c > '9')
throw new InputMismatchException();
m /= 10;
res += (c - '0') * m;
}
}
return res * sgn;
}
while (isSpaceChar(c))
int sgn = 1;
if (c == '-') {
sgn = -1;
}
long res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
} while (!isSpaceChar(c));
return res * sgn;
}
public boolean isSpaceChar(int c)
{
if (filter != null)
return filter.isSpaceChar(c);
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}

public String next()
{
}

public interface SpaceCharFilter
{
public boolean isSpaceChar(int ch);
}
}
class OutputWriter {
private  PrintWriter writer;
public OutputWriter(OutputStream outputStream)
{
writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
}
public OutputWriter(Writer writer)
{
this.writer = new PrintWriter(writer);
}
public void print(Object... objects)
{
for (int i = 0; i < objects.length; i++)
{
if (i != 0)
writer.print(' ');
writer.print(objects[i]);
}
}
public void printLine(Object... objects)
{
print(objects);
writer.println();
}
public void close()
{
writer.close();
}
public void flush()
{
writer.flush();
}
} ``````
Copy The Code &

Input

cmd
5

Output

cmd
34560