Extra Long Factorials Solution

Extra Long Factorials Solution

The factorial of the integer n, written n!, is defined as:

Calculate and print the factorial of a given integer.

For example, if , we calculate  and get .

Function Description

Complete the extraLongFactorials function in the editor below. It should print the result and return.

extraLongFactorials has the following parameter(s):

  • n: an integer

Note: Factorials of  can't be stored even in a  long long variable. Big integers must be used for such calculations. Languages like Java, Python, Ruby etc. can handle big integers, but we need to write additional code in C/C++ to handle huge values.

We recommend solving this challenge using BigIntegers.

Input Format

Input consists of a single integer


Output Format

Print the factorial of .

Sample Input

Sample Output


Solution in Python

def extraLongFactorials(n):
    p = 1
    for i in range(1,n+1):
    return p

n = int(input())

Subscribe to The Poor Coder | Algorithm Solutions

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]