2016年12月25日日曜日

161225(2)

Ruby


Carlitz-Riordan q-Catalan number(2)

q に値を入れてみた。

def A(q, n)
  ary = [1]
  (1..n).each{|i| ary << (0..i - 1).inject(0){|s, j| s + q ** j * ary[j] * ary[i - 1 - j]}}
  ary
end

m = 15
n = 10
(-m).upto(m){|i| p [i, A(i, n)]}

出力結果
[-15, [1, 1, -14, -3179, 10723006, 542873722666, -412243647724631324, -4695713624367570470762339, 802306685647013388432209000866246, 2056224284624166189326137448360909656319806, -79048169125296659081612136450818524821473078349801284]]
[-14, [1, 1, -13, -2575, 7060859, 271264155177, -145891830663946653, -1098498082881654016852191, 115796529856845631007039381658635, 170891251717103120492481858367229118002777, -3530792146361605405371444355660685372328514965522829]]
[-13, [1, 1, -12, -2053, 4506516, 128719671458, -47792455652926776, -230685150666052748440241, 14475150636847360774217794485492, 11807825094529414273687354438435675691966, -125216073787815189597144109941517357809545986473192]]
[-12, [1, 1, -11, -1607, 2773837, 57523871473, -14313665005500443, -42740403316561070472599, 1531465840001130532816209452989, 658502282312683496975363165471547847201, -3397727136707136901749274995744498255546402996011]]
[-11, [1, 1, -10, -1231, 1636130, 23957879562, -3858392581773300, -6835385537899011365535, 133202313157282627679850238250, 28553099061411464607955930776882965774, -67326713945643235114071801430954895411640907660]]
[-10, [1, 1, -9, -919, 917271, 9174563561, -917438025443049, -917439860513400673559, 9174396770273536422744011031, 917439695376166450708460281823359721, -917439693541287252616828116888122637934368489]]
[-9, [1, 1, -8, -665, 483544, 3173511682, -187386353065808, -99585165693268026701, 476312561203989614441440600, 20503694883570579788445502041773422, -7943551457092331370323478258038812629918704]]
[-8, [1, 1, -7, -463, 236201, 967959393, -31716161292711, -8314264834902720111, 17436260499054618815283977, 292531943497569504642889779448001, -39262972238604561849241166988994502971207]]
[-7, [1, 1, -6, -307, 104742, 251699498, -4229811552588, -497641562809372379, 409828230340907182689774, 2362579011761419853955236859806, -95338580221916838164306067991935130836]]
[-6, [1, 1, -5, -191, 40915, 53110057, -412878084725, -19264066381851695, 5392667163887921078275, 9057620836725683164283293369, -91279931160615494871228103624209605]]
[-5, [1, 1, -4, -109, 13436, 8425506, -26312994024, -411193252871529, 32123650782112689116, 12548365338592689141400286, -24508500955561451477156078353144]]
[-4, [1, 1, -3, -55, 3429, 885137, -904638963, -3707218743911, 60731665539301365, 3980231929565571675617, -1043385959026442521712292579]]
[-3, [1, 1, -2, -23, 586, 48778, -11759396, -8596478231, 18783386191762, 123275424165263086, -2426183754235085042972]]
[-2, [1, 1, -1, -7, 47, 873, -26433, -1749159, 220526159, 56904690761, -29022490524961]]
[-1, [1, 1, 0, -1, 0, 2, 0, -5, 0, 14, 0]]
[0, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]
[1, [1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796]]
[2, [1, 1, 3, 17, 171, 3113, 106419, 7035649, 915028347, 236101213721, 121358941877763]]
[3, [1, 1, 4, 43, 1252, 104098, 25511272, 18649337311, 40823535032644, 267924955577741566, 5274102955963545775864]]
[4, [1, 1, 5, 89, 5885, 1518897, 1558435125, 6386478643785, 104648850228298925, 6858476391221411106209, 1797922152786660462507074405]]
[5, [1, 1, 6, 161, 20466, 12833546, 40130703276, 627122621447281, 48995209411107768186, 19138851672289046707772366, 37380607950584029444762130426196]]
[6, [1, 1, 7, 265, 57799, 75025897, 583552122727, 27227375795690569, 7621977131953256556295, 12802009986716861649949951657, 129014790439200398432389878440405671]]
[7, [1, 1, 8, 407, 140456, 337520898, 5673390747984, 667480099386451779, 549699898523248769128232, 3168911624115201777713785471406, 127877020635106970108300418456422667248]]
[8, [1, 1, 9, 593, 304857, 1249312673, 40939981188777, 10732252327798007281, 22507185898866512901924729, 377607964391970470904956530918721, 50681683810611444451901001718927186370889]]
[9, [1, 1, 10, 829, 606070, 3977651242, 234884294434900, 124827614155955343925, 597046858511123656669455550, 25700910736350654917922270058287454, 9957059456624152426469878400757673046606860]]
[10, [1, 1, 11, 1121, 1123331, 11235577641, 1123580257785051, 1123582505161487376561, 11235827298801257861061293171, 1123582752351801734250808539216885881, 1123582754598967452437582737448130799606015691]]
[11, [1, 1, 12, 1475, 1966284, 28792327202, 4637090716230072, 8214898341126993790759, 160085145151052208703206236460, 34315672899472590258644379240786601502, 80914561747054018478916529869278801828481880296]]
[12, [1, 1, 13, 1897, 3281941, 68060935633, 16935874936243549, 50570285458951728780409, 1812024860211310933873859090917, 779137526211873277333060572704071052641, 4020178500812183819597479479649746538770964386733]]
[13, [1, 1, 14, 2393, 5262362, 150308905098, 55808945055454332, 269379229895845048811001, 16903147725326197024967576562914, 13788416914956150844762214226519339383726, 146219258556891930208266584229687972600181963879364]]
[14, [1, 1, 15, 2969, 8153055, 313224146537, 168460090064098575, 1268426649629557391924665, 133709300241289796232737115885375, 197326722248932275335833526988910108874249, 4076976640513216882869248895614781143147222246805615]]
[15, [1, 1, 16, 3631, 12262096, 620793238786, 471416107658044576, 5369725044142720196094091, 917467875703536347458248015349456, 2351369819214194491379980656123736092564046, 90394554988282798598300931934940056315505771981088736]]

0 件のコメント:

コメントを投稿