我試圖計算帕斯卡三角形的第100行中的特定條目是否可以被3整除。我使用公式nCr計算了這個,其中n = 100,r是不同的第100行中的條目。 我使用以下代碼來計算組合計算大數的組合
public static double Combination(int n, int m, double comb)
{
for (int r = -1; ++r < m;)
comb = comb * (n - r)/(r + 1);
return comb;
}
但對於值如100C16我得到含有十進制和e在其大的數字。 我在互聯網上搜索發現,實際上有12個數字是不能被3整除的,但是我的程序給了我63個數字,這些數字在第100行不能被3整除,這是錯誤的。可以告訴我它是什麼,做錯了。
請與你的同學分享這個鏈接。我厭倦了這個問題。 http://math.stackexchange.com/questions/117978/finding-number-of-entries-not-divisible-by-number-n-in-100th-row-of-pascals-tri – 2012-03-09 21:23:52
可能的重複[Find number的數字不能被x在第100行的Pascal Triangle中整除](http://stackoverflow.com/questions/9607923/find-number-of-digits-not-divisible-by-x-in-100th-row-of- pascal-triangle) – 2012-03-09 22:16:42