Re: range error - or "How to take the factorial of a huge

2004-04-09 Thread Dar Scott
On Friday, April 9, 2004, at 12:36 PM, Jim Witte wrote: The MathWorld page on Stirling's approximation gives a formula for (log n!) as well. The first formula gives an *exect* (I think) derivation for ln n! as ln n! = sum(k=1..n, ln k) This is mathematically exact, but computationally it cann

Re: range error - or "How to take the factorial of a huge

2004-04-09 Thread Jim Witte
2. Work with logs of expressions. The MathWorld page on Stirling's approximation gives a formula for (log n!) as well. The first formula gives an *exect* (I think) derivation for ln n! as ln n! = sum(k=1..n, ln k) which is approximately (by changing that summation to an integral from 1..n an

Re: range error - or "How to take the factorial of a huge

2004-04-09 Thread Stephen Messimer
Message: 4 Date: Thu, 8 Apr 2004 23:59:06 -0600 From: Dar Scott <[EMAIL PROTECTED]> Subject: Re: range error - or "How to take the factorial of a huge number" To: How to use Revolution <[EMAIL PROTECTED]> Message-ID: <[EMAIL PROTECTED]> Content-Type: text/pla

Re: range error - or "How to take the factorial of a huge

2004-04-09 Thread Dar Scott
On Friday, April 9, 2004, at 07:15 AM, Stephen Messimer wrote: I will use the information you provided in your earlier post and see if that works. Didn't Jim provide some cool info? A couple ideas: 1. Instead of fact(200)/fact(196) do this: 197 * 198 * 199 * 200 2. Work with logs of expression

Re: Re: range error - or "How to take the factorial of a huge

2004-04-09 Thread Stephen Messimer
Jim Thanks for your help. After looking at your first response I thought that It might be possible to combine the two sets of calculations and sum them but as it turns out the factorial of any number > 169 results in an overflow error so it seems doing the factorials of numbers <= 169 and t

Re: range error - or "How to take the factorial of a huge number"

2004-04-09 Thread Dar Scott
On Thursday, April 8, 2004, at 11:05 PM, Jim Witte wrote: This is factorial in acculator-passing-style, which is closely related to continuation-passing-style, but I can't do the CPS in my head, Is this the same as tail recursion optimization? Dar Scott __

Re: range error - or "How to take the factorial of a huge number"

2004-04-08 Thread Jim Witte
Type Operators *: range error (overflow) Another possibility aside from recursion overflow (the more obvious one - I'm missing the forrest for the trees here) is that the number is just too big for whatever datatype MetaCard is using to represent numbers. I don't know how you get around this

Re: range error - or "How to take the factorial of a huge number"

2004-04-08 Thread Jim Witte
.Oh God, Just thinking off the top of my head, I'm thinking recusion overflow (unless the RunRev compiler automatically CPS's recursive function automatically, which I doubt) Try this script (written off the top of my head function factorial (n) return factAPS(n, 1)-- start the