2016年11月6日日曜日

161106

Ruby


二項係数の二乗の性質について(3)

 重複組合せnHr を((n, r)) と表示することにする。
二項係数の二乗に関する次の式を確認してみる。

5 * binomial(3n - 1, n - 1)^2 = Sum_{k=0..n} binomial(n, k)^2 * ((2n, 2n - k))

def ncr(n, r)
  return 1 if r == 0
  (n - r + 1..n).inject(:*) / (1..r).inject(:*)
end

def nhr(n, r)
  ncr(n + r - 1, r)
end

n = 50
(1..n).each{|i|
  k = (0..i).inject(0){|s, j| s + ncr(i, j) ** 2 * nhr(2 * i, 2 * i - j)}
  p [i, k, k == 5 * ncr(3 * i - 1, i - 1) ** 2]
}

出力結果
[1, 5, true]
[2, 125, true]
[3, 3920, true]
[4, 136125, true]
[5, 5010005, true]
[6, 191456720, true]
[7, 7511688000, true]
[8, 300509773245, true]
[9, 12203515878125, true]
[10, 501501625750125, true]
[11, 20809145549088000, true]
[12, 870387258154050000, true]
[13, 36652108385188109520, true]
[14, 1552335454661154248000, true]
[15, 66074189571630987633920, true]
[16, 2824635346319475590467005, true]
[17, 121213601091557180872903125, true]
[18, 5219287249322913057702081125, true]
[19, 225415876207126914865606050000, true]
[20, 9761977978250952558199317886125, true]
[21, 423796228858502525036923296895125, true]
[22, 18439281497705737654570601671200000, true]
[23, 803920759903721244436553246147712000, true]
[24, 35114811386490330902527405779216450000, true]
[25, 1536419605787133040572870669115810556880, true]
[26, 67330826461763685406071018635669587555920, true]
[27, 2954958272205246175172671455895038581888000, true]
[28, 129860275059297834326052719572023136549750080, true]
[29, 5714100615689791045509061011263620283683272000, true]
[30, 251726667426709061508704392746751645541565246720, true]
[31, 11101639641168495945252540008389522630769995207680, true]
[32, 490107678206611390297579895276970421471138365640125, true]
[33, 21657835530998409267377651899694060901145836096476805, true]
[34, 957928021604441458796952933805035548870180388171778125, true]
[35, 42405506365910124695749494875183102906606941194955938000, true]
[36, 1878721297106371909447193335226357078352343727411077705125, true]
[37, 83297904182966626065307278082564328745492088967518833028125, true]
[38, 3695896535373490814451768948155704857090002311253533143427920, true]
[39, 164098011252062318795154200003397539340371320812182134214088000, true]
[40, 7290706377677765874813559343627535473384875913997522298753603245, true]
[41, 324119213898933218121907761534375424099857170623741315154598559805, true]
[42, 14417698049244933814515809681182381784327626199848666419901200078125, true]
[43, 641698556810269758323741068201979859915662206761149661915470860800000, true]
[44, 28575840845033885242110477609131258038844430408760279905768876180000000, true]
[45, 1273178729200484750162347884415797979751768588325276827637010380960800000, true]
[46, 56753466775643973680930178572355732719403373330074873511543557525379200000, true]
[47, 2531039788842194784413462616965585893377627717723137864478826363648320000000, true]
[48, 112927722363440790088019300576036110444804531455934370346025549638133008450000, true]
[49, 5040680542424620476003380571241674395828657079887329811956805576711483051250000, true]
[50, 225090550010539077888751060088984021679182030739485202473522736592300559951922000, true]

0 件のコメント:

コメントを投稿

注: コメントを投稿できるのは、このブログのメンバーだけです。