2016年10月23日日曜日

161023

Ruby


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

調べてみた。

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

n = 20
# A000984, A002893
(1..10).each{|m|
  p [m, (0..n).map{|i| (0..i).inject(0){|s, j| s += ncr(i, j) ** 2 * ncr(m * j, j)}}]
}
# A000984, A001850, A069835, A084771, A084772, A098659
(1..10).each{|m|
  p [m, (0..n).map{|i| (0..i).inject(0){|s, j| s += ncr(i, j) ** 2 * m ** j}}]
}

出力結果
[1, [1, 2, 6, 20, 70, 252, 924, 3432, 12870, 48620, 184756, 705432, 2704156, 10400600, 40116600, 155117520, 601080390, 2333606220, 9075135300, 35345263800, 137846528820]]
[2, [1, 3, 15, 93, 639, 4653, 35169, 272835, 2157759, 17319837, 140668065, 1153462995, 9533639025, 79326566595, 663835030335, 5582724468093, 47152425626559, 399769750195965, 3400775573443089, 29016970072920387, 248256043372999089]]
[3, [1, 4, 28, 247, 2428, 25354, 275131, 3066277, 34849852, 402093076, 4694932978, 55352304022, 657845010619, 7871232172366, 94724844421249, 1145633887949572, 13915946040679228, 169683028207454776, 2076037223668708420, 25476829469571084952, 313498615395379684978]]
[4, [1, 5, 45, 509, 6413, 85905, 1196685, 17128053, 250070797, 3706975553, 55615458745, 842564575605, 12868046157101, 197864638432609, 3060110887820661, 47563717531514409, 742517043038854925, 11635942905649118401, 182966892478537864905, 2885764469167617149673, 45638625745153668217113]]
[5, [1, 6, 66, 906, 13826, 224381, 3788886, 65762416, 1164612226, 20943777246, 381233419941, 7007891120346, 129868918270886, 2423167941563336, 45476377273387616, 857760512176294031, 16249675671731558786, 309024593740363735376, 5896867792889553462966, 112867958900372744703396, 2166238063693067293669701]]
[6, [1, 7, 91, 1465, 26155, 496507, 9810325, 199311133, 4132608235, 87027705565, 1855235109091, 39942124752493, 866973187536373, 18947650485816007, 416523970183397125, 9202604015487297415, 204214399806020313835, 4549218602869842700957, 101688395801200492630105, 2279976276268033816122835, 51259967965260439610727955]]
[7, [1, 8, 120, 2213, 45144, 978783, 22092141, 512858410, 12153443800, 292557554486, 7129819294795, 175496459522161, 4355343272113821, 108834629524066727, 2735634324280391598, 69110425611793822488, 1753640324354772175064, 44670154701639034032060, 1141780670618473123095054, 29273567557930766098490652, 752593570757539142786274219]]
[8, [1, 9, 153, 3177, 72793, 1771609, 44887689, 1169986729, 31135903321, 841817012481, 23044963096953, 637220251156377, 17766016320154249, 498766595075902825, 14085186827342507113, 399789323594343683977, 11397717695256167169625, 326204401288401181999009, 9368158282825680500041809, 269866988771745229093165545, 7795428619152692439350967993]]
[9, [1, 10, 190, 4384, 111358, 3002410, 84268864, 2433407140, 71756200702, 2150006083633, 65232989379190, 1999321899802138, 61788594917439424, 1922902935023934640, 60197224303084368340, 1894121816601726592984, 59863806235896437303038, 1899377542598578927057342, 60472091704340846514570913, 1931226660986739070824413560, 61845629098194034391535233158]]
[10, [1, 11, 231, 5861, 163351, 4828761, 148569081, 4703287551, 152064309591, 4996222906871, 166244136125981, 5588183891002581, 189421174150256521, 6465866809260014401, 222027856476278145531, 7663192982386032259611, 265670945050036721562711, 9246435630434736868600701, 322927966828323370815719631, 11312927089732114758878746581, 397415361150797310406640375101]]
[1, [1, 2, 6, 20, 70, 252, 924, 3432, 12870, 48620, 184756, 705432, 2704156, 10400600, 40116600, 155117520, 601080390, 2333606220, 9075135300, 35345263800, 137846528820]]
[2, [1, 3, 13, 63, 321, 1683, 8989, 48639, 265729, 1462563, 8097453, 45046719, 251595969, 1409933619, 7923848253, 44642381823, 252055236609, 1425834724419, 8079317057869, 45849429914943, 260543813797441]]
[3, [1, 4, 22, 136, 886, 5944, 40636, 281488, 1968934, 13875544, 98365972, 700701808, 5011371964, 35961808432, 258805997752, 1867175631136, 13500088649734, 97794850668952, 709626281415076, 5157024231645616, 37528209137458516]]
[4, [1, 5, 33, 245, 1921, 15525, 127905, 1067925, 9004545, 76499525, 653808673, 5614995765, 48416454529, 418895174885, 3634723102113, 31616937184725, 275621102802945, 2407331941640325, 21061836725455905, 184550106298084725, 1619284832403678081]]
[5, [1, 6, 46, 396, 3606, 33876, 324556, 3151896, 30915046, 305543556, 3038019876, 30354866856, 304523343996, 3065412858696, 30946859111256, 313206733667376, 3176825392214406, 32284147284682596, 328643023505612596, 3350574568434600456, 34206348493399513876]]
[6, [1, 7, 61, 595, 6145, 65527, 712909, 7863667, 87615745, 983726695, 11112210781, 126142119187, 1437751935361, 16443380994775, 188609259215725, 2168833084841395, 24994269200292865, 288596644195946695, 3337978523215692925, 38666734085509918675, 448523930340837682945]]
[7, [1, 8, 78, 848, 9766, 116208, 1411404, 17383584, 216294534, 2712176048, 34217133028, 433826815584, 5522845782364, 70550459395424, 903871957376088, 11609390838397248, 149439879433714374, 1927359943975516464, 24900198783317300724, 322185768219251912928, 4174511185830878156916]]
[8, [1, 9, 97, 1161, 14721, 192969, 2582881, 35066313, 481003009, 6649718409, 92497952097, 1293068265993, 18150727906689, 255660741430857, 3611681892224097, 51151047016594761, 726034745427826689, 10325288148885543177, 147093267997642581601, 2098692320836733189001, 29984858605394405293441]]
[9, [1, 10, 118, 1540, 21286, 304300, 4443580, 65830600, 985483270, 14869654300, 225759595348, 3444812388280, 52781007848284, 811510465220920, 12513859077134008, 193460383702061200, 2997463389599395270, 46532910920993515900, 723626591914643806180, 11270311875128088314200, 175774584776587378711156]]
[10, [1, 11, 141, 1991, 29761, 460251, 7272861, 116619591, 1889815041, 30869546411, 507406003501, 8382404928711, 139054141487041, 2314783947556091, 38647630102736061, 646908600416279751, 10852435135445442561, 182414141648658652491, 3071424519623622600141, 51795261103319478048711, 874662233881165045064001]]

0 件のコメント:

コメントを投稿