Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
improving speed of factorial function #1170
Hi, I modified factorial functions in gamma.js, permutation.js and combination.js for regular number to speed up the run time by modifying how product is calculated. (see: productrange.js for more info on how it is done). I tried to implement the same algorithm for big number but it ends up slower compared to the original, which is a bit of a surprise since, on regular number, the trend is that it will outperform the original method. I am still rather new to open source contribution so feedback is appreciated.
here is the log of performance for permutation function original vs new:
ans for original algorithm for 50P25: 1.9607814681608194e+39
here is one for combination function:
ans for original algorithm for 50C25: 126410606437752
here is one for factorial:
ans for original algorithm for 50! : 3.0414093201713376e+64
wow, that's impressive!!! Thanks a lot @honeybar .
I think your work is ready to be merged as is, though I have a few remarks: