Extra Long Factorials

The factorial of the integer , written , 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 
Constraints
Output Format
Print the factorial of .
Sample Input
Sample Output
Explanation
25! = 25 x 24 x 23 x...x3x2x1

 php

<?php

// Complete the extraLongFactorials function below.
function extraLongFactorials($n) {
$fact = gmp_fact($n);
echo gmp_strval($fact);
}

$stdin = fopen("php://stdin", "r");

fscanf($stdin, "%d\n", $n);

extraLongFactorials($n);

fclose($stdin);

Comments

Popular posts from this blog

Intro to Tutorial Challenges

Mini-Max Sum