thanks
nabeel
P********************Palestinian Statehood Now!*****************************
E Nabeel Ibrahim | *
A ibr...@mentor.cc.purdue.edu | Oh, if humans could only *
C Electrical Engineering | multitask... *
E Purdue University | *
!**********"Racist, Sexist, Anti-gay, Operation Rescue, Go Away!"***********
MATLAB does not have a factorial function, so n! must be computed by
prod(1:n)
or, possibly with roundoff error, by
gamma(n+1)
But, be careful, either of these quantities overflow for n > 170.
If you actually want n! to compute something like
n!/(k!*(n-k)!)
for large n, you should use
exp(sum(log(1:n))-sum(log(1:k))-sum(log(1:(n-k))))
It's not as slow as it looks, and it doesn't overflow.
-- Cleve Moler
>If you actually want n! to compute something like
> n!/(k!*(n-k)!)
>for large n, you should use
> exp(sum(log(1:n))-sum(log(1:k))-sum(log(1:(n-k))))
I tried both of the above methods, but they don't seem to work
in loops. Specifically, I was trying to compute n!/(k!*(n-k)!)
for values of k from 0 to 10 while holding n at a constant
value of 10. Each time, n!/(k!*(n-k)!) was only computed
once. Any suggestions on how to fix this??
Thanks