PDA

View Full Version : n!


tony873004
Sep8-04, 11:11 PM
I know that n! for 6 is 6*5*4*3*2*1 but what is 6.1! ? My calculator says 868.957. How do they come up with this?

I'm trying to write a computer program that mimics the calculator program that comes with windows.

I know that using my above formula that I have to make an exception for 0!=1, and Invalid Input for Function for a negative number.

Anything else I should know about n! ??

Tide
Sep8-04, 11:24 PM
The factorial is a special case of the gamma function. The relationship is x! = \Gamma (x+1) and the factorial is usually reserved for nonnegative integers.

Janitor
Sep8-04, 11:25 PM
This question crops up here every now and then, I have noticed. Here is one website on the relation between the gamma function and factorials.

http://mathworld.wolfram.com/GammaFunction.html

tony873004
Sep8-04, 11:30 PM
Thanks for your replies. This forum is great!
That link scared me away. I think I might drop the n! button from my calculator since I can't make it do non-integers and the Windows calculator can.

Tide
Sep8-04, 11:41 PM
Actually, it's not too hard do. You can create a table of values for the gamma function over the interval (0, 1] from which you can obtain values of \Gamma (x) for larger x values using the fact that \Gamma (x+1) = x \Gamma(x). If you want greater accuracy you can write a simple interpolation routine.

tony873004
Sep9-04, 12:04 AM
But what would I do with the values between 0 & 1? Add them to the integer's factorial, or multiply them (probably not. I'm guessing they'd be less than 1, and 6.1! > 6!). I'm not sure I could trust my interpolation routine. If I could come up with that I could probably forget the table altogether. I could also make the Calculator generate an error message on non-integer inputs. Do people ever use the n! button? I never have.

Tide
Sep9-04, 12:25 AM
But what would I do with the values between 0 & 1? Add them to the integer's factorial, or multiply them (probably not. I'm guessing they'd be less than 1, and 6.1! > 6!). I'm not sure I could trust my interpolation routine. If I could come up with that I could probably forget the table altogether. I could also make the Calculator generate an error message on non-integer inputs. Do people ever use the n! button? I never have.

No. You would branch to one of two subroutines - one for integer values and one for noninteger values.