Problem source: https://www.hackerrank.com/challenges/extra-long-factorials

You are given an integer N. Print the factorial of this number.

N!=N×N−1×N−2×⋯×3×2×1

Note: Factorials of N>20 can’t be stored even in a 64−bit 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 such large values.

We recommend solving this challenge using BigIntegers.

**Input Format**

Input consists of a single integer N.

**Constraints**

1≤N≤100

**Output Format**

Output the factorial of N.

**Sample Input**

```
25
```

**Sample Output**

`15511210043330985984000000 `

class Extra_Long_Factorials_Hackerrank

{

static void Main(string[] args)

{

int N = Convert.ToInt16(Console.ReadLine());

Console.WriteLine(Factorials(N));

}

private static BigInteger Factorials(int N)

{

if (N == 1)

{

return 1;

}

return N * Factorials(N – 1);

}

}

### Like this:

Like Loading...

*Related*

Reblogged this on A place to reblog the efforts of people, their piece of knowledge, research and much more things..

LikeLike