problem using factorial in matlab
Mostra commenti meno recenti
I wanted to calculate 200! but after 170! matlab starts showing result NaN. So is there any way possible to calculate this number using matlab???
Risposta accettata
Più risposte (1)
Steven Lord
il 8 Nov 2017
0 voti
If you're computing this as an intermediary step to compute a final result and will immediately divide it by the factorial of some other number, don't compute the result that way. My guess is that you're trying to compute the binomial coefficient nchoosek, in which case you should use that function.
If you can't use nchoosek (because your homework tells you not to, for example) you could turn a ratio of two factorials into the appropriate call to prod by using cancellation. [To see what I mean, write out how you would compute factorial(8) and factorial(4) on paper. Determine how you would use those representations to compute factorial(8)/factorial(4) without actually calling factorial, then generalize that process.]
Categorie
Scopri di più su Performance and Memory in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!