2020年8月8日土曜日

200808

Ruby


A243631 とA336727

A307883 とA307884 と似た関係式をもつ。

# A307883とA307884
def A(k, n)
  i, a, b = 0, 1, k + 1
  ary = [1]
  while i < n
    i += 1
    a, b = b, ((k + 1) * (2 * i + 1) * b - (k - 1) ** 2 * i * a) / (i + 1)
    ary << a
  end
  ary
end

# A243631とA336727
def B(k, n)
  i, a, b = 0, 1, 1
  ary = [1]
  while i < n
    i += 1
    a, b = b, ((k + 1) * (2 * i + 1) * b - (k - 1) ** 2 * (i - 1) * a) / (i + 2)
    ary << a
  end
  ary
end

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

出力結果
[-10, [1, -9, 61, -189, -2559, 59751, -727859, 5968611, -23658239, -239767209, 6676401501]]
[-9, [1, -8, 46, -80, -2330, 39952, -391796, 2396512, -1665530, -187855280, 3005297956]]
[-8, [1, -7, 33, -7, -1919, 24633, -186591, 715449, 3834369, -102211207, 1079883553]]
[-7, [1, -6, 22, 36, -1434, 13644, -73604, 71688, 3315334, -41652036, 283869972]]
[-6, [1, -5, 13, 55, -959, 6475, -20195, -84425, 1657345, -11975525, 40678573]]
[-5, [1, -4, 6, 56, -554, 2376, -804, -67344, 530406, -1852504, -3106124]]
[-4, [1, -3, 1, 45, -255, 477, 2689, -25203, 82945, 90045, -2379519]]
[-3, [1, -2, -2, 28, -74, -92, 1324, -3656, -4826, 70228, -197372]]
[-2, [1, -1, -3, 11, 1, -81, 141, 363, -1791, 479, 13597]]
[-1, [1, 0, -2, 0, 6, 0, -20, 0, 70, 0, -252]]
[0, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]
[1, [1, 2, 6, 20, 70, 252, 924, 3432, 12870, 48620, 184756]]
[2, [1, 3, 13, 63, 321, 1683, 8989, 48639, 265729, 1462563, 8097453]]
[3, [1, 4, 22, 136, 886, 5944, 40636, 281488, 1968934, 13875544, 98365972]]
[4, [1, 5, 33, 245, 1921, 15525, 127905, 1067925, 9004545, 76499525, 653808673]]
[5, [1, 6, 46, 396, 3606, 33876, 324556, 3151896, 30915046, 305543556, 3038019876]]
[6, [1, 7, 61, 595, 6145, 65527, 712909, 7863667, 87615745, 983726695, 11112210781]]
[7, [1, 8, 78, 848, 9766, 116208, 1411404, 17383584, 216294534, 2712176048, 34217133028]]
[8, [1, 9, 97, 1161, 14721, 192969, 2582881, 35066313, 481003009, 6649718409, 92497952097]]
[9, [1, 10, 118, 1540, 21286, 304300, 4443580, 65830600, 985483270, 14869654300, 225759595348]]
[10, [1, 11, 141, 1991, 29761, 460251, 7272861, 116619591, 1889815041, 30869546411, 507406003501]]
[-10, [1, 1, -9, 71, -459, 1901, 4851, -214709, 2829321, -25102759, 141253551]]
[-9, [1, 1, -8, 55, -296, 802, 6832, -138941, 1397080, -9274418, 26549776]]
[-8, [1, 1, -7, 41, -175, 177, 6153, -78951, 588833, -2530591, -4090471]]
[-7, [1, 1, -6, 29, -90, -118, 4404, -38219, 194286, -269506, -6250068]]
[-6, [1, 1, -5, 19, -35, -203, 2575, -14705, 38425, 177769, -2904605]]
[-5, [1, 1, -4, 11, -4, -174, 1176, -3729, -3364, 116846, -719224]]
[-4, [1, 1, -3, 5, 9, -103, 357, -131, -5295, 29297, -55539]]
[-3, [1, 1, -2, 1, 10, -38, 28, 289, -1262, 1054, 11044]]
[-2, [1, 1, -1, -1, 5, -3, -21, 51, 41, -391, 407]]
[-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, 11, 45, 197, 903, 4279, 20793, 103049, 518859]]
[3, [1, 1, 4, 19, 100, 562, 3304, 20071, 124996, 793774, 5120632]]
[4, [1, 1, 5, 29, 185, 1257, 8925, 65445, 491825, 3768209, 29324405]]
[5, [1, 1, 6, 41, 306, 2426, 20076, 171481, 1500666, 13386206, 121267476]]
[6, [1, 1, 7, 55, 469, 4237, 39907, 387739, 3858505, 39130777, 402972031]]
[7, [1, 1, 8, 71, 680, 6882, 72528, 788019, 8766248, 99362894, 1143498224]]
[8, [1, 1, 9, 89, 945, 10577, 123129, 1476841, 18130401, 226739489, 2878666857]]
[9, [1, 1, 10, 109, 1270, 15562, 198100, 2596645, 34825150, 475697854, 6595646860]]
[10, [1, 1, 11, 131, 1661, 22101, 305151, 4335711, 63009881, 932449961, 14004694451]]

0 件のコメント:

コメントを投稿

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