mfb
Mentor
- 37,371
- 14,197
It can be approximated, but you need an extremely precise result. Also, the formula doesn't work for the product of the first n primes, or subsets of it.a1call said:A factorial (and by extension multifactorial) can be evaluated within a range formulaic using Sterling's formula. You don't need tho multiply all primes. The calculated ranges can be used to proof if a sum is prime.
Well, you can speed that up significantly. Make 1013 multiplications of 12-digit numbers, 5*1012 multiplications of 24-digit numbers, ... so memory usage is only ld(1013)*1013*6 bytes or ~1000 TB.Vanadium 50 said:That means the products will take up about a terabyte, which means ~1000 seconds just to get them in and out of memory. That means the whole process will take 10^16 seconds, or of order a billion years.
The last multiplication step is the most elaborate one, but it can be done in O(n log n log log n). You don't need a supercomputer to do that in a year.