I got a problem to solve. I need write a PHP scipt to calculate a factorial for a number from 1 to 1000, what seems easy, by it also says that "but if it gives INF for 999, your algorithm is wrong". I'm confused.
Asked
Active
Viewed 278 times
-1
-
1what did you try so far ? please post – Akshay Hegde Jun 26 '17 at 16:40
-
See perhaps [Is there a BigInteger class for PHP?](https://stackoverflow.com/questions/4427020/is-there-a-biginteger-class-in-php) – lurker Jun 26 '17 at 16:40
-
1because the PHP couldn't handle the number with that much number of digits, – Shobi Jun 26 '17 at 16:43
1 Answers
2
There is function in php to do this
<?php
$fact = gmp_fact(999); // 999 * 998 * 997, ... etc
echo gmp_strval($fact)
?>
This returns the factorial , for reference http://php.net/manual/en/function.gmp-fact.php

Prags
- 811
- 5
- 17