January 8, 200224 yr Hi good folks, Is there a way to specify a Factorial function in File Maker, such as (Field-1)! Thank you
January 8, 200224 yr Here's the calc: If((integer = Int(integer)) and (integer > 0), integer * If(integer > 1, integer-1, 1) * If(integer > 2, integer-2, 1) * If(integer > 3, integer-3, 1), TextToNum("") ) Notice that one line repeats, except that the numbers increment. Rather than type each line by hand, create a calc field and as many records as you need to handle your largest factorial. Export the calc to a tab delimited file. Open the file in a text editor, and copy and paste into your factorial calc. Here's the factorial builder calc: "If(integer > " & Status(CurrentRecordNumber) & ", integer-" & Status(CurrentRecordNumber) & ", 1) *"
January 9, 200224 yr Try this: code: Round( (x+1) ^ (x+1) * Exp( - (x+1)) * Sqrt(2 * 3.1415926536/(x+1)) * ( 1+ 1/(12*(x+1)) + 1/(288*(x+1)^2) - 139/(51840*(x+1)^3) - 571/(2488320*(x+1)^4) ),0) This is essentially a series expansion of the Gamma function (actually Gamma[x+1]) which is equal to Factorial(x) for integer values. Make special note of the alternating addition and subtraction of terms in the last 4 lines of the main part of the formula. [ January 08, 2002: Message edited by: BobWeaver ]
January 9, 200224 yr Integer! Could be done with a script, but not a calculation: If Integer = Truncate(Integer, 0) Set Field (gCounter, Integer) Set Field (gFactorial, Integer) Loop Set Field (gFactorial, gFactorial*Counter-1) Set Field (gCounter, gCounter-1) Exit Loop If (gCounter=1) End Loop Else Show Message ("This number is not an integer.") End If
Create an account or sign in to comment