nchoosek---Result may not be exact !?

23 ビュー (過去 30 日間)
Li Fei
Li Fei 2014 年 4 月 25 日
回答済み: Image Analyst 2014 年 4 月 25 日
Hi, everybody
I am using matlab nchoosek(n,k) function to calculate the combinatorial number. When n or k is large, e.g. nchoosek(500,250), the function returns a warning "Result may not be exact. Coefficient is greater than 9.007199e+15 and is only accurate to 15 digits". Does this mean that the result is not right? How can I get the exact result, through some other functions in matlab or other software?
Thanks in advance!

回答 (2 件)

Niklas Nylén
Niklas Nylén 2014 年 4 月 25 日
編集済み: Niklas Nylén 2014 年 4 月 25 日
Your answer is in the range of 10^150 which meas that the number needs to be represented by approximately 500 bits.
You could try to use one of the variable precision integer toolboxes available on the file exchange but my first choice for solving a single problem would be to use wolfram alpha: https://www.wolframalpha.com/input/?i=500+choose+250
Another option is to write a program in python which does not have a limit on the number of digits in an integer.

Image Analyst
Image Analyst 2014 年 4 月 25 日
Why do you need that many in the first place? Are you sure you don't want randperm() instead? What are you going to do with all of these?

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by