wu :: forums (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi)
riddles >> cs >> Bits in Factorial N
(Message started by: johny_cage on Nov 26th, 2007, 5:30am)

Title: Bits in Factorial N
Post by johny_cage on Nov 26th, 2007, 5:30am
Consider the problem of computing N! = 1 . 2 . 3 ...  . N
If N is an n-bit number, how many bits long is N!, approximately in terms of theta.

Title: Re: Bits in Factorial N
Post by Grimbal on Nov 26th, 2007, 8:10am
If N is a n-bit number, N! is a log2(2n-1!) to log2(2n!) bits long number.  8)

More seriously, what is theta?  (besides the greek letter)

Title: Re: Bits in Factorial N
Post by pex on Nov 26th, 2007, 8:42am
Theta is pretty much the same as Big O. (See the introduction here (http://en.wikipedia.org/wiki/Big_O_notation).)

Of course, as log(N!) is O(N logN), we have that log(2n!) = O(2nlog(2n)) = O(2n n log2) = O(n 2n).

Title: Re: Bits in Factorial N
Post by wanderer on Nov 26th, 2007, 12:15pm
Or can we analyze like this ?
O(N!) = O(N^N)
and O(N^N) has O(n^2) bits where n is the number of bits in N

Title: Re: Bits in Factorial N
Post by SMQ on Nov 26th, 2007, 12:42pm
Using Stirling's approximation (http://en.wikipedia.org/wiki/Stirling%27s_approximation) to the factorial, N! http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/approx.gif http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/surd.gif(2http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/pi.gifN) NN/eN, so:
log2(N!) http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/approx.gif log2((2http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/pi.gifN)1/2NN/eN)
  = (1 + log2 http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/pi.gif + log2 N)/2 + N log2 N - N log2 e
  http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/approx.gif 1.326 + n/2 + (n - 1.443)N where n = log2 N.

--SMQ

Title: Re: Bits in Factorial N
Post by johny_cage on Nov 27th, 2007, 6:23am
@All

Plz explain how you are getting this bound????



Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board