Small Factorials

Practice this coding question on Coding Gurukul.

Problem statement

A workshop organiser places n distinct display cards in a row. Every card must be used exactly once, and changing the order creates a different arrangement. The organiser wants the number of possible arrangements for several small values of n. These counts grow quickly, so the display must support exact integers rather than approximate scientific notation. Your task For each test case, calculate n!, the product of every integer from 1 through n. By convention, 0! equals 1. Print the complete decimal representation of the factorial with no separators, rounding or exponent notation. Important details The largest answers do not fit into a standard 64-bit integer. Use arbitrary-precision arithmetic or implement multiplication on a decimal digit representation. Every test case asks for a fresh factorial value. Worked example For n = 5, the arrangement count is 5 × 4 × 3 × 2 × 1 = 120. With no cards, there is one empty arrangement, so 0! is 1.

Input format

First line: T. Next T lines: n.

Output format

Print the exact factorial for each test case.

Constraints

1 <= T <= 100; 0 <= n <= 100.

Sample input

2
5
0

Sample output

120
1

Sign in to run or submit a solution in C++, Java or Python.