   Nth Factorial
  Hi,So:3! = 3*2*1 = 63!! = (3!)! = 6! = 6*5*4*3*2*1 = 7203!!! = ((3!)!)! = (6!)! = 720! ≈ 2.60121894*101746But actually finding the values really isn't going to work for things like 3!!!!, 7!!!, etc.  I've tried several approximation functions, but they get overflow errors.  Is there a way to get factorials of extremely large numbers (obviously in exponential or hierarchical exponential notation)?Thanks,-G   
  Hi,I've tried Stirling's approximation, but again, I get an overflow error.I'm pretty sure that I need an approximate answer in exponential form.  I'm trying to find (specifically) ~7!!!, 6!!!!, 5!!!!!, 4!!!!!!, 3!!!!!!!, and 2!!!!!!!!.  G   ;  I'm not sure about repeated factorials, but using Sterling's approximation you can go beyond the range of normal overflows:factorial :: Int -> (Float,Int)factorial n = (man,exp);  where ee  = n*log(n)-n; //sterling's approximation   de  = ee/log(10);   exp = int(de);   man = pow(10,de-di);example:factorial 2425  = (5.779070731652062,  7154)  = 5.779..e+7154factorial 10000 = (1.1354838653097798, 35657) = 1.135..e+35657;  Have you considered rolling out your own "big integer" type that internally allocates its own memory as its value gets larger?  You will very likely need _something_ of the sort, since fixed-size integers CAN and WILL overflow.  I'm sure there are some math libraries that provide such functionality for your language of choice. (BigInt looks nice.)Naturally, if speed is the more pinnacle underlying issue, you will likely need, as you mentioned, some manner of speedier algorithm or approximation.  Best of luck!   ;  you could use sterling for repeated factorials:sterling is log(n!) = nlog(n) - nfrom which you get an answer for n! = e^x (which i converted into the form a*10^b)but you could easily do again:log((e^x)!) = xe^x - xso say, define:fact_exp(x) = xe^x - xwhich takes e^x, and computes log((e^x)!)doing this, i calculate 5!!!!! = 3.1089987919938853e+214125no idea if that's right or if i even implemented my own method correctly lol :P   ;  Yep, but 7!! is already x*1010,000's.  I need to take that number to a factorial.  Nested exponential representations?In Python, I tried:def approx_factorial(n):    return n*e**n - nprint "Fact 5",approx_factorial(approx_factorial(5))Which gives an overflow error.Did you use "^" instead of a power operator, maybe?  In C, C++, and Python, it's a bitwise XOR.   ;  no i was applying the formula repeatedly rather than in a loop and forgot to use the correct value in the exponential :P   ;  Why would you ever need such a thing? 7!! is more than the number of atoms in the universe.  If you ACTUALLY need to do calculations like this, it would probably be better to invent a number format that could work intrinsically on numbers represented that way.  For example, maybe you invent your own version of "factorial scientific" notation that has an int for the number on the left and another int for the number of iterations you take the factorial of.   