Advertisement

Formulae for n!

Started by July 18, 2003 06:33 AM
8 comments, last by Last Attacker 21 years, 7 months ago
Hey! Do you guys know if there is a physical formulae for calculating the factorial of something? I know that for instance 3! = 1 x 2 x 3 = 6 but is there a formulae for that? I tried to come up with one but no success (YET! I''m a little optimistic Any way if anyone knows... Please post! Thanks for your input! ----------=Last Attacker=---------- E-mail: laextr@icqmail.com
"Take delight in the Lord and He will give you your heart's desires" - Psalm 37:4My Blog
The formula for n! is

         | n > 0 -> n x f(n-1)f(n) = | n = 0 -> 1       | n < 0 -> undefined


[edit]
formatting
[/edit]

[edited by - darookie on July 18, 2003 7:48:59 AM]
Advertisement
there is an aproximation formula (stirlington):

n! = (n/e)^n * sqrt(2*pi*n)


T2k

[edited by - T2k on July 18, 2003 7:50:52 AM]
Stirling's Formula : n! ~ sqrt(2πn) (n/e)n

Note that it is an equivalence, not an equality.

See also mathworld.

edit: reformulation & formatting.


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]


[edited by - Fruny on July 18, 2003 8:18:23 AM]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
n! = 1 x 2 x 3 x ... x n is a formula (in fact it´s even the definition of the factorial; it derives from statistics and gives you the number of permutations of a given set of n elements) so what are you asking for ?

For very big numbers you can use the approximation ln(n!) = n(ln(n) -1). This should be an approximation of the so called Stirling Formula (try googling for it, the version I found in my book looks wrong). Problem with this is that I can´t really tell you if it´s useable with computers since it´s commonly used in analytical calculation using numbers that your computer can´t display (say n = 10^23 where 60! = 10^82, so guess (10^23)! ...).

If for some unknown reason you want to compute something like (2.3)! (the factorial of real numbers) you can use the gamma function. To qoute from my math book:

G(x>0) = Integrate(0 to infinity){ t^(x-1)*exp(-t) dt },

G(n+1) = n!
xG(x) = G(x+1)
( maximum respect if your trying came even close to this ;] )

One last word: Maybe this explains why I didn´t really get your question, but: What the hell is a physical formula ??? As far as I got it physics is a way to translate nature into a mathematical desription and applying boudary conditions to it that seem appropriate (setting inappropriate boundary conditions strange things might occur like you end up becoming famous ).

EDIT: Looks like some other people responded to your post while I was writing. I´d like to add something to their replies:
As far as I got it the Stirling Formular is not an approximation. It´s correct but it contains an infinite sum. The equations given above are approximations of it by taking the first summand and ignoring the rest of the sum. If I´m wrong about this feel free to correct me; I´m always interested in learning.

[edited by - Atheist on July 18, 2003 8:18:38 AM]
Wow!

I never thought that there even was going to be a formulae, but thanks very much you guys!

To me a formulae is not a short cut but a one-line execuation of an equasion to get to an answer, like 2*3 is a shortcut to get to 6 but is infact a non-loop solution to 2+2+2 to get to 6.

When I asked for a formulae for n! I hoped that it would be something like the 2*3 thing (above), to get an answer without going through a loop.

Thanks for your input!

----------=Last Attacker=----------

E-mail: laextr@icqmail.com

[edited by - Last Attacker on July 18, 2003 8:25:26 AM]
"Take delight in the Lord and He will give you your heart's desires" - Psalm 37:4My Blog
Advertisement
We are, the knights who say... n!
Beer - the love catalystgood ol' homepage
quote:
Original post by Dredge-Master
We are, the knights who say... n!


Good one !
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Maybe I just skipped over it, but no one has mentioned the gamma function yet.
<a href="http://mathworld.wolfram.com/GammaFunction.html">here</a>

I think products are easier than integrals.

Brendan
It was mentioned, but as a solution to taking factorials of real numbers. But hey, if it works on real numbers it''ll work on integers too. I would love to see how the gamma function works. *clicks link quickly* =)
Over the centuries, mankind has tried many ways of combating the forces of evil...prayer,fasting, good works and so on. Up until Doom, no one seemed to have thought about thedouble-barrel shotgun. Eat leaden death, demon... -- Terry Pratchett

This topic is closed to new replies.

Advertisement