bbaliner Posted January 8, 2002 Posted January 8, 2002 Hi good folks, Is there a way to specify a Factorial function in File Maker, such as (Field-1)! Thank you
Thom Posted January 8, 2002 Posted January 8, 2002 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) *"
BobWeaver Posted January 9, 2002 Posted January 9, 2002 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 ]
rdhaden Posted January 9, 2002 Posted January 9, 2002 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
bbaliner Posted January 11, 2002 Author Posted January 11, 2002 Thank you all for your help. Thom, your calc worked like a charm!
Recommended Posts
This topic is 8423 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now