Jump to content

This topic is 8423 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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) *"

Posted

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 ]

Posted

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.