Factorial
Practice this coding question on Coding Gurukul.
Problem statement
A photo studio wants to count the possible orders of n distinct trophies on a shelf. Every trophy must appear exactly once in an arrangement. Your task Compute n factorial, the product of all integers from 1 through n. Important details The empty shelf has one arrangement, so 0! is defined as 1. For positive n, multiply every factor through n exactly once. Do not return n squared or the sum of the factors. No modulus is used: print the full exact result. The upper input limit is chosen so the answer fits in a signed 64-bit integer, although many answers do not fit in 32 bits. Worked example For four trophies, there are 4 choices for the first position, then 3, 2, and 1, giving 4! = 24 arrangements.
Input format
One integer n.
Output format
Print n!.
Constraints
0 <= n <= 20.
Sample input
4
Sample output
24
Sign in to run or submit a solution in C++, Java or Python.