+ 1

Highly! specific method for very big factorial calculation in php

i have been working on a statistical web app that calculates various statistical parameters sometimes its needed to calculate very large factorials which i am doing it by working on the log of it the problem is that when working on very large populations like1000000 the little error which this method has got becomes so important is there a more specific way to calculate very big factorials with like 50 digits precison? *already tried using loops it makes the page take a lot of time to load and causes error

23rd Sep 2017, 7:28 PM
amirabas
4 Respostas
+ 2
thanks for your respond yes i already tried that it makes it possible to have a very specific answer but the problem is while using this method i will have to start it from 0 which requires very very precise calculations which i dont need and neither is executable on my server for example probability of 0 positives in a sample which sometimes would be like e-400 which requires precison to be up to 450 digits or else it echoes 0 and the rest of the probabilities which were supposed to be calculated on the top of that will be zero either and increasing precison up to 450 digits makes server to take more than 2 minutes calculation and therefore casues an error
23rd Sep 2017, 8:12 PM
amirabas
+ 1
if you are not familiar with php any answers with other languages would be appericiated as well i will convert it to php by myself thank you in advance for your answers🌷
23rd Sep 2017, 7:31 PM
amirabas
+ 1
Are you utilizing memoization with your factorial equation? If not you should look into it for use with your larger numbers. It will help speed things up. A few examples: http://eddmann.com/posts/implementing-and-using-memoization-in-php/ http://stevephillips.me/blog/quick-and-dirty-php-memoization https://www.simonholywell.com/post/2015/05/memoization-or-function-cache/
23rd Sep 2017, 8:01 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Ok, if you're using memoization, you should continue to do so properly, and also, for working with extremely large numbers with PHP you should also be using one of the following PHP modules: BCMath, GMP, php-bignumber. Beyond this I'm not sure I can be of any further assistance.
23rd Sep 2017, 8:36 PM
ChaoticDawg
ChaoticDawg - avatar