2021年12月13日月曜日

211213

Ruby


ナゴヤ三角形について(3)

一つの角が90度の、全ての辺の長さが整数の三角形について考えます。
このうち、辺の長さが互いに素な場合(原始ピタゴラス数)を計算すると以下のようになります。

def A(n)
  ary = []
  (1..n).each{|i|
    (i + 1..n).each{|j|
      if i.gcd(j) == 1 && (i - j) % 2 > 0
        x, y, z = j * j, i * j, i * i
        b = y + y
        c = x + z 
        a = x - z
        ary << [a, b, c]
      end
    }
  }
  ary
end

n = 10
A(n).sort.each{|i| p i}

出力結果
[3, 4, 5]
[5, 12, 13]
[7, 24, 25]
[9, 40, 41]
[11, 60, 61]
[13, 84, 85]
[15, 8, 17]
[15, 112, 113]
[17, 144, 145]
[19, 180, 181]
[21, 20, 29]
[33, 56, 65]
[35, 12, 37]
[39, 80, 89]
[45, 28, 53]
[51, 140, 149]
[55, 48, 73]
[63, 16, 65]
[65, 72, 97]
[77, 36, 85]
[91, 60, 109]
[99, 20, 101]

2021年12月12日日曜日

211212

Ruby


ナゴヤ三角形について(2)

一つの角が120度の、全ての辺の長さが整数の三角形について考えます。
このうち、辺の長さが互いに素な場合を計算すると以下のようになります。

def A(n)
  ary = []
  (1..n).each{|i|
    (i + 1..n).each{|j|
      if i.gcd(j) == 1 && (i - j) % 3 > 0
        x, y, z = j * j, i * j, i * i
        b = x + y + y
        c = x + y + z 
        a = y + y + z
        ary << [b - a, a, c]
      end
    }
  }
  ary
end

n = 10
A(n).sort.each{|i| p i}

出力結果
[3, 5, 7]
[5, 16, 19]
[7, 33, 37]
[8, 7, 13]
[9, 56, 61]
[11, 85, 91]
[13, 120, 127]
[15, 161, 169]
[16, 39, 49]
[17, 208, 217]
[19, 261, 271]
[24, 11, 31]
[24, 95, 109]
[32, 175, 193]
[35, 13, 43]
[40, 51, 79]
[45, 32, 67]
[55, 57, 97]
[56, 115, 151]
[63, 17, 73]
[65, 88, 133]
[77, 40, 103]
[80, 19, 91]
[91, 69, 139]

2021年12月11日土曜日

211211

Ruby


ナゴヤ三角形について(1)

この記事は
日曜数学 Advent Calendar 2021 (https://adventar.org/calendars/6887)
の12/11 分として書いております。

ナゴヤ三角形とは、一松 信氏命名の三角形の名称で、
一つの角が60度の、全ての辺の長さが整数の三角形(ただし、正三角形は除く)
のことです。
大学受験数学で頻出のものに、(3, 7, 8)や(5, 7, 8)があります。
辺の長さが互いに素な場合を原始的(primitive)とよびます。

原始的なナゴヤ三角形は、適当な正の整数m, n(0 < n < m)により、
2*m*n+n^2, m^2+m*n+n^2, m^2+2*m*n
もしくは
m^2 - n^2, m^2+m*n+n^2, m^2+2*m*n
のいずれかの形で一通りで表されます。

ここで注意しないといけない事は、
m, nに適当な値を入れると原始的でなくなる
ということです。
(m, n)=1, m-nが3で割り切れない
という条件が必要です。 

これらをもとに、原始的なナゴヤ三角形を計算すると以下のようになります。

def A(n)
  ary = []
  (1..n).each{|i|
    (i + 1..n).each{|j|
      if i.gcd(j) == 1 && (i - j) % 3 > 0
        x, y, z = j * j, i * j, i * i
        b = x + y + y
        c = x + y + z 
        a = y + y + z
        ary << [    a, b, c]
        ary << [b - a, b, c]
      end
    }
  }
  ary
end

n = 10
A(n).sort.each{|i| p i}

出力結果
[3, 8, 7]
[5, 8, 7]
[5, 21, 19]
[7, 15, 13]
[7, 40, 37]
[8, 15, 13]
[9, 65, 61]
[11, 35, 31]
[11, 96, 91]
[13, 48, 43]
[13, 133, 127]
[15, 176, 169]
[16, 21, 19]
[16, 55, 49]
[17, 80, 73]
[17, 225, 217]
[19, 99, 91]
[19, 280, 271]
[24, 35, 31]
[24, 119, 109]
[32, 77, 67]
[32, 207, 193]
[33, 40, 37]
[35, 48, 43]
[39, 55, 49]
[40, 91, 79]
[40, 117, 103]
[45, 77, 67]
[51, 91, 79]
[55, 112, 97]
[56, 65, 61]
[56, 171, 151]
[57, 112, 97]
[63, 80, 73]
[65, 153, 133]
[69, 160, 139]
[77, 117, 103]
[80, 99, 91]
[85, 96, 91]
[88, 153, 133]
[91, 160, 139]
[95, 119, 109]
[115, 171, 151]
[120, 133, 127]
[161, 176, 169]
[175, 207, 193]
[208, 225, 217]
[261, 280, 271]

2021年11月6日土曜日

211106

Ruby


Numbers k such that k^2 is palindromic in base b

出力してみた。

def A(k, n)
  i = (n * n).to_s(k)
  i == i.reverse
end

def B(k, n)
  m = 0
  cnt = 0
  ary = []
  while cnt < n
    if A(k, m)
      cnt += 1
      ary << m
    end
    m += 1
  end
  ary
end

n = 10
(2..36).each{|i|
  p [i, B(i, n)]
}

出力結果
[2, [0, 1, 3, 4523, 11991, 18197, 141683, 1092489, 3168099, 6435309]]
[3, [0, 1, 2, 4, 10, 11, 20, 22, 28, 34]]
[4, [0, 1, 5, 17, 21, 65, 71, 83, 257, 273]]
[5, [0, 1, 2, 6, 26, 31, 66, 126, 156, 626]]
[6, [0, 1, 2, 7, 37, 43, 76, 91, 217, 259]]
[7, [0, 1, 2, 4, 8, 10, 11, 20, 32, 40]]
[8, [0, 1, 2, 3, 6, 9, 11, 27, 65, 73]]
[9, [0, 1, 2, 10, 20, 82, 91, 100, 164, 730]]
[10, [0, 1, 2, 3, 11, 22, 26, 101, 111, 121]]
[11, [0, 1, 2, 3, 6, 12, 24, 26, 72, 84]]
[12, [0, 1, 2, 3, 13, 26, 145, 157, 169, 179]]
[13, [0, 1, 2, 3, 14, 28, 170, 183, 196, 209]]
[14, [0, 1, 2, 3, 15, 24, 30, 47, 165, 197]]
[15, [0, 1, 2, 3, 4, 8, 12, 16, 19, 32]]
[16, [0, 1, 2, 3, 17, 34, 257, 273, 289, 305]]
[17, [0, 1, 2, 3, 4, 6, 12, 18, 28, 36]]
[18, [0, 1, 2, 3, 4, 19, 38, 49, 65, 325]]
[19, [0, 1, 2, 3, 4, 10, 20, 40, 60, 64]]
[20, [0, 1, 2, 3, 4, 21, 42, 45, 63, 273]]
[21, [0, 1, 2, 3, 4, 22, 29, 44, 56, 66]]
[22, [0, 1, 2, 3, 4, 23, 39, 46, 51, 69]]
[23, [0, 1, 2, 3, 4, 12, 24, 48, 57, 58]]
[24, [0, 1, 2, 3, 4, 5, 10, 15, 20, 25]]
[25, [0, 1, 2, 3, 4, 26, 52, 66, 78, 626]]
[26, [0, 1, 2, 3, 4, 5, 9, 18, 27, 54]]
[27, [0, 1, 2, 3, 4, 5, 14, 28, 56, 84]]
[28, [0, 1, 2, 3, 4, 5, 29, 58, 87, 785]]
[29, [0, 1, 2, 3, 4, 5, 30, 60, 69, 81]]
[30, [0, 1, 2, 3, 4, 5, 31, 41, 62, 93]]
[31, [0, 1, 2, 3, 4, 5, 8, 16, 24, 32]]
[32, [0, 1, 2, 3, 4, 5, 33, 66, 70, 99]]
[33, [0, 1, 2, 3, 4, 5, 34, 43, 60, 68]]
[34, [0, 1, 2, 3, 4, 5, 35, 70, 105, 127]]
[35, [0, 1, 2, 3, 4, 5, 6, 12, 18, 24]]
[36, [0, 1, 2, 3, 4, 5, 37, 74, 111, 133]]

2021年10月9日土曜日

211009

Ruby


Stirling number

第1種スターリング数および第2種スターリング数を計算してみた。
第1種については
「数の本」、「コンピュータの数学」
にある通り、符号なしで出力してみる。

# 符号は無視
def stirling(n, k = 1)
  a = [1]
  p [0, a]
  (1..n).each{|i|
    a << 0
    b = [0]
    (0..i - 1).each{|j|
      if k == 2
        b[j + 1] = a[j] + (j + 1) * a[j + 1]
      else
        b[j + 1] = a[j] + (i - 1) * a[j + 1]
      end
    }
    a = b
    p [i, a]
  }
end

n = 10
stirling(n)
p ""
stirling(n, 2)

出力結果
[0, [1]]
[1, [0, 1]]
[2, [0, 1, 1]]
[3, [0, 2, 3, 1]]
[4, [0, 6, 11, 6, 1]]
[5, [0, 24, 50, 35, 10, 1]]
[6, [0, 120, 274, 225, 85, 15, 1]]
[7, [0, 720, 1764, 1624, 735, 175, 21, 1]]
[8, [0, 5040, 13068, 13132, 6769, 1960, 322, 28, 1]]
[9, [0, 40320, 109584, 118124, 67284, 22449, 4536, 546, 36, 1]]
[10, [0, 362880, 1026576, 1172700, 723680, 269325, 63273, 9450, 870, 45, 1]]
""
[0, [1]]
[1, [0, 1]]
[2, [0, 1, 1]]
[3, [0, 1, 3, 1]]
[4, [0, 1, 7, 6, 1]]
[5, [0, 1, 15, 25, 10, 1]]
[6, [0, 1, 31, 90, 65, 15, 1]]
[7, [0, 1, 63, 301, 350, 140, 21, 1]]
[8, [0, 1, 127, 966, 1701, 1050, 266, 28, 1]]
[9, [0, 1, 255, 3025, 7770, 6951, 2646, 462, 36, 1]]
[10, [0, 1, 511, 9330, 34105, 42525, 22827, 5880, 750, 45, 1]]

2021年10月7日木曜日

211007

Ruby


37で割り切れるpandigital number

2016年JJMO予選の問題をプログラミングで解いてみた。
0を含めない場合についても考えてみた。

def A(m, n)
  ary = []
  (m..n).to_a.permutation{|i|
    if i[0] > 0
      j = i.join.to_i
      ary << j if j % 37 == 0
    end
  }
  ary
end

def show(ary, n)
  p ary.size
  # 小さいものをn個表示
  p ary[0..n - 1]
  # 大きいものをn個表示
  p ary[-n..-1]
end

n = 10
show(A(0, 9), n)
# もし1から9の数字だったら
show(A(1, 9), n)

出力結果
85104
[1023654987, 1023657984, 1023684957, 1023687954, 1023745896, 1023746895, 1023795846, 1023796845, 1023845796, 1023846795]
[9876142305, 9876145302, 9876302145, 9876305142, 9876342105, 9876345102, 9876412035, 9876415032, 9876432015, 9876435012]
9072
[123564978, 123568974, 123574968, 123578964, 123645897, 123647895, 123695847, 123697845, 123845697, 123847695]
[987263415, 987265413, 987413265, 987415263, 987463215, 987465213, 987532146, 987536142, 987542136, 987546132]

2021年9月19日日曜日

210919

Ruby


π を分数で近似(4)

π = 4/(1 + 1^2/(3 + 2^2/(5 + 3^2/(7 + ...
を利用して、近似してみた。

def A(k, m, n)
  a, b = k, m
  ary = [k]
  (1..n).each{|i|
    a, b = b, (2 * i + 1) * b + i ** 2 * a
    ary << a
  }
  ary
end

n = 20
# A054765
p ary0 = A(0, 1, n)
# A012244
p ary1 = A(1, 1, n)
p (0..n).map{|i| 4 * ary0[i] / ary1[i].to_r}

出力結果
[0, 1, 3, 19, 160, 1744, 23184, 364176, 6598656, 135484416, 3108695040, 78831037440, 2189265960960, 66083318415360, 2154235544616960, 75425161203302400, 2822882994841190400, 112463980097804697600, 4752052488932268441600, 212264271642182654361600, 9993797542549672427520000]
[1, 1, 4, 24, 204, 2220, 29520, 463680, 8401680, 172504080, 3958113600, 100370793600, 2787459998400, 84139894238400, 2742857884166400, 96034297911552000, 3594206259195552000, 143193586818810528000, 6050501147565883008000, 270263264589232282368000, 12724498233251342778240000]
[(0/1), (4/1), (3/1), (19/6), (160/51), (1744/555), (644/205), (2529/805), (183296/58345), (3763456/1197945), (4317632/1374345), (54743776/17425485), (1013549056/322622685), (30594128896/9738413685), (35618973952/11337871545), (10392576224/3308059755), (3111643512832/990466892415), (123968232030208/39460313827935), (48501417558016/15438480702645), (1083228572868608/344802363740835), (4080033616887808/1298715036217599)]

2021年9月1日水曜日

210901

Ruby


A213261

p(7*n+5) を出力してみた。

def s(k, n)
  s = 0
  (1..n).each{|i| s += i if n % i == 0 && i % k == 0}
  s
end

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

n = 15
a = [7, 49]
ary = (0..1).map{|i| p [0] * i + A([[7, 4 * (i + 1) - 1], [1, -4 * (i + 1)]], n)}
(0..n).each{|i|
  print "#{(0..1).inject(0){|s, j| s + a[j] * ary[j][i]}} = "
  (0..1).each{|j|
    print " + " if j > 0
    print "#{a[j]} * #{ary[j][i]}"
  }
  puts
}

出力結果
[1, 4, 14, 40, 105, 252, 574, 1237, 2568, 5138, 9988, 18893, 34937, 63238, 112370, 196244]
[0, 1, 8, 44, 192, 726, 2464, 7704, 22521, 62281, 164252, 415796, 1015334, 2401462, 5519640, 12363062, 27047913]
7 = 7 * 1 + 49 * 0
77 = 7 * 4 + 49 * 1
490 = 7 * 14 + 49 * 8
2436 = 7 * 40 + 49 * 44
10143 = 7 * 105 + 49 * 192
37338 = 7 * 252 + 49 * 726
124754 = 7 * 574 + 49 * 2464
386155 = 7 * 1237 + 49 * 7704
1121505 = 7 * 2568 + 49 * 22521
3087735 = 7 * 5138 + 49 * 62281
8118264 = 7 * 9988 + 49 * 164252
20506255 = 7 * 18893 + 49 * 415796
49995925 = 7 * 34937 + 49 * 1015334
118114304 = 7 * 63238 + 49 * 2401462
271248950 = 7 * 112370 + 49 * 5519640
607163746 = 7 * 196244 + 49 * 12363062

2021年8月1日日曜日

210801

Ruby


A282919

p(49*n+47) を出力してみた。

def s(k, n)
  s = 0
  (1..n).each{|i| s += i if n % i == 0 && i % k == 0}
  s
end

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

n = 15
a =
[7 ** 2 * 2546, 7 ** 4 * 48934, 7 ** 5 * 1418989, 7 ** 7 * 2488800, 7 ** 9 * 2394438,
 7 ** 11 * 1437047, 7 ** 12 * 4043313, 7 ** 15 * 161744, 7 ** 17 * 32136, 7 ** 18 * 31734,
 7 ** 20 * 3120, 7 ** 22 * 204, 7 ** 24 * 8, 7 ** 25]
ary = (0..13).map{|i| p [0] * i + A([[7, 4 * (i + 1)], [1, -4 * (i + 1) - 1]], n)}
(0..n).each{|i|
  print "#{(0..13).inject(0){|s, j| s + a[j] * ary[j][i]}} = "
  (0..13).each{|j|
    print " + " if j > 0
    print "#{a[j]} * #{ary[j][i]}"
  }
  puts
}

出力結果
[1, 5, 20, 65, 190, 506, 1265, 2986, 6745, 14645, 30767, 62745, 124706, 242110, 460337, 858673]
[0, 1, 9, 54, 255, 1035, 3753, 12483, 38701, 113193, 315013, 839802, 2155905, 5352252, 12894426, 30233558, 69160869]
[0, 0, 1, 13, 104, 637, 3276, 14820, 60697, 229360, 810498, 2705118, 8592857, 26134654, 76476816, 216174700, 592220696, 1576826355]
[0, 0, 0, 1, 17, 170, 1275, 7905, 42619, 206091, 912459, 3753328, 14500320, 53053498, 185046190, 618555931, 1990227519, 6186291009, 18633598578]
[0, 0, 0, 0, 1, 21, 252, 2233, 16170, 100926, 560945, 2837398, 13265679, 57989435, 239125579, 936702879, 3505361650, 12590400326, 43572202835, 145770820937]
[0, 0, 0, 0, 0, 1, 25, 350, 3575, 29575, 209405, 1312675, 7452201, 38939275, 189537775, 867436570, 3760131375, 15529994130, 61413915500, 233488417752, 856388420815]
[0, 0, 0, 0, 0, 0, 1, 29, 464, 5365, 49880, 394632, 2750969, 17296732, 99742368, 534126988, 2681856693, 12722233068, 57373155952, 247218913828, 1022189562610, 4070289420139]
[0, 0, 0, 0, 0, 0, 0, 1, 33, 594, 7667, 79101, 691119, 5299019, 36518791, 230122266, 1343028082, 7331536586, 37731144564, 184232285897, 857974579385, 3827695162667, 16420097827188]
[0, 0, 0, 0, 0, 0, 0, 0, 1, 37, 740, 10545, 119510, 1142338, 9548849, 71529474, 488650453, 3084466705, 18173253703, 100751920597, 529029597362, 2645187324766, 12651654794629, 58105915432081]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 41, 902, 14063, 173635, 1801745, 16300739, 131814181, 969824701, 6579564585, 41587633402, 246925024493, 1386436741480, 7402293438974, 37755020009290, 184685764132377]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 45, 1080, 18285, 244260, 2733804, 26606745, 230915656, 1819708110, 13198528010, 89041203249, 563420646090, 3366705675744, 19105222953420, 103448715353372, 536621238174195]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 49, 1274, 23275, 334425, 4015011, 41818315, 387605443, 3256150548, 25135003348, 180196297050, 1210028211210, 7663549175191, 46039891115155, 263630633610437, 1444741006154614]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 53, 1484, 29097, 447426, 5734918, 63638001, 627260142, 5594403499, 45779730871, 347453597091, 2466970932027, 16501339314082, 104588498225862, 631215364345159, 3642533720923593]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 57, 1710, 35815, 586815, 7997157, 94175267, 983458849, 9279004863, 80218101555, 642408637594, 4807304399931, 33855173217278, 225702273908048, 1431470152072364, 8673471170235715]
124754 = 124754 * 1 + 117490534 * 0 + 23848948123 * 0 + 2049633818400 * 0 + 96624210037866 * 0 + 2841511464047921 * 0 + 55964656476536913 * 0 + 767889588864220592 * 0 + 7475814197492884152 * 0 + 51676077116090188566 * 0 + 248951870848549443120 * 0 + 797603493910929561996 * 0 + 1532649851044531315208 * 0 + 1341068619663964900807 * 0
118114304 = 124754 * 5 + 117490534 * 1 + 23848948123 * 0 + 2049633818400 * 0 + 96624210037866 * 0 + 2841511464047921 * 0 + 55964656476536913 * 0 + 767889588864220592 * 0 + 7475814197492884152 * 0 + 51676077116090188566 * 0 + 248951870848549443120 * 0 + 797603493910929561996 * 0 + 1532649851044531315208 * 0 + 1341068619663964900807 * 0
24908858009 = 124754 * 20 + 117490534 * 9 + 23848948123 * 1 + 2049633818400 * 0 + 96624210037866 * 0 + 2841511464047921 * 0 + 55964656476536913 * 0 + 767889588864220592 * 0 + 7475814197492884152 * 0 + 51676077116090188566 * 0 + 248951870848549443120 * 0 + 797603493910929561996 * 0 + 1532649851044531315208 * 0 + 1341068619663964900807 * 0
2366022741845 = 124754 * 65 + 117490534 * 54 + 23848948123 * 13 + 2049633818400 * 1 + 96624210037866 * 0 + 2841511464047921 * 0 + 55964656476536913 * 0 + 767889588864220592 * 0 + 7475814197492884152 * 0 + 51676077116090188566 * 0 + 248951870848549443120 * 0 + 797603493910929561996 * 0 + 1532649851044531315208 * 0 + 1341068619663964900807 * 0
133978259344888 = 124754 * 190 + 117490534 * 255 + 23848948123 * 104 + 2049633818400 * 17 + 96624210037866 * 1 + 2841511464047921 * 0 + 55964656476536913 * 0 + 767889588864220592 * 0 + 7475814197492884152 * 0 + 51676077116090188566 * 0 + 248951870848549443120 * 0 + 797603493910929561996 * 0 + 1532649851044531315208 * 0 + 1341068619663964900807 * 0
5234371069753672 = 124754 * 506 + 117490534 * 1035 + 23848948123 * 637 + 2049633818400 * 170 + 96624210037866 * 21 + 2841511464047921 * 1 + 55964656476536913 * 0 + 767889588864220592 * 0 + 7475814197492884152 * 0 + 51676077116090188566 * 0 + 248951870848549443120 * 0 + 797603493910929561996 * 0 + 1532649851044531315208 * 0 + 1341068619663964900807 * 0
154043597379576030 = 124754 * 1265 + 117490534 * 3753 + 23848948123 * 3276 + 2049633818400 * 1275 + 96624210037866 * 252 + 2841511464047921 * 25 + 55964656476536913 * 1 + 767889588864220592 * 0 + 7475814197492884152 * 0 + 51676077116090188566 * 0 + 248951870848549443120 * 0 + 797603493910929561996 * 0 + 1532649851044531315208 * 0 + 1341068619663964900807 * 0
3617712763867604423 = 124754 * 2986 + 117490534 * 12483 + 23848948123 * 14820 + 2049633818400 * 7905 + 96624210037866 * 2233 + 2841511464047921 * 350 + 55964656476536913 * 29 + 767889588864220592 * 1 + 7475814197492884152 * 0 + 51676077116090188566 * 0 + 248951870848549443120 * 0 + 797603493910929561996 * 0 + 1532649851044531315208 * 0 + 1341068619663964900807 * 0
70593393646562135510 = 124754 * 6745 + 117490534 * 38701 + 23848948123 * 60697 + 2049633818400 * 42619 + 96624210037866 * 16170 + 2841511464047921 * 3575 + 55964656476536913 * 464 + 767889588864220592 * 33 + 7475814197492884152 * 1 + 51676077116090188566 * 0 + 248951870848549443120 * 0 + 797603493910929561996 * 0 + 1532649851044531315208 * 0 + 1341068619663964900807 * 0
1178875491155735802646 = 124754 * 14645 + 117490534 * 113193 + 23848948123 * 229360 + 2049633818400 * 206091 + 96624210037866 * 100926 + 2841511464047921 * 29575 + 55964656476536913 * 5365 + 767889588864220592 * 594 + 7475814197492884152 * 37 + 51676077116090188566 * 1 + 248951870848549443120 * 0 + 797603493910929561996 * 0 + 1532649851044531315208 * 0 + 1341068619663964900807 * 0
17229817230617210720599 = 124754 * 30767 + 117490534 * 315013 + 23848948123 * 810498 + 2049633818400 * 912459 + 96624210037866 * 560945 + 2841511464047921 * 209405 + 55964656476536913 * 49880 + 767889588864220592 * 7667 + 7475814197492884152 * 740 + 51676077116090188566 * 41 + 248951870848549443120 * 1 + 797603493910929561996 * 0 + 1532649851044531315208 * 0 + 1341068619663964900807 * 0
224282898599046831034631 = 124754 * 62745 + 117490534 * 839802 + 23848948123 * 2705118 + 2049633818400 * 3753328 + 96624210037866 * 2837398 + 2841511464047921 * 1312675 + 55964656476536913 * 394632 + 767889588864220592 * 79101 + 7475814197492884152 * 10545 + 51676077116090188566 * 902 + 248951870848549443120 * 45 + 797603493910929561996 * 1 + 1532649851044531315208 * 0 + 1341068619663964900807 * 0
2636785814481962651219075 = 124754 * 124706 + 117490534 * 2155905 + 23848948123 * 8592857 + 2049633818400 * 14500320 + 96624210037866 * 13265679 + 2841511464047921 * 7452201 + 55964656476536913 * 2750969 + 767889588864220592 * 691119 + 7475814197492884152 * 119510 + 51676077116090188566 * 14063 + 248951870848549443120 * 1080 + 797603493910929561996 * 49 + 1532649851044531315208 * 1 + 1341068619663964900807 * 0
28316911738879831363625420 = 124754 * 242110 + 117490534 * 5352252 + 23848948123 * 26134654 + 2049633818400 * 53053498 + 96624210037866 * 57989435 + 2841511464047921 * 38939275 + 55964656476536913 * 17296732 + 767889588864220592 * 5299019 + 7475814197492884152 * 1142338 + 51676077116090188566 * 173635 + 248951870848549443120 * 18285 + 797603493910929561996 * 1274 + 1532649851044531315208 * 53 + 1341068619663964900807 * 1
280403140023083872114273884 = 124754 * 460337 + 117490534 * 12894426 + 23848948123 * 76476816 + 2049633818400 * 185046190 + 96624210037866 * 239125579 + 2841511464047921 * 189537775 + 55964656476536913 * 99742368 + 767889588864220592 * 36518791 + 7475814197492884152 * 9548849 + 51676077116090188566 * 1801745 + 248951870848549443120 * 244260 + 797603493910929561996 * 23275 + 1532649851044531315208 * 1484 + 1341068619663964900807 * 57
2580469549453004933593920862 = 124754 * 858673 + 117490534 * 30233558 + 23848948123 * 216174700 + 2049633818400 * 618555931 + 96624210037866 * 936702879 + 2841511464047921 * 867436570 + 55964656476536913 * 534126988 + 767889588864220592 * 230122266 + 7475814197492884152 * 71529474 + 51676077116090188566 * 16300739 + 248951870848549443120 * 2733804 + 797603493910929561996 * 334425 + 1532649851044531315208 * 29097 + 1341068619663964900807 * 1710

2021年7月31日土曜日

210731

Ruby


A278559

p(25*n+24) を出力してみた。

def s(k, n)
  s = 0
  (1..n).each{|i| s += i if n % i == 0 && i % k == 0}
  s
end

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

n = 10
a = [5 ** 2 * 63, 5 ** 5 * 52, 5 ** 7 * 63, 5 ** 10 * 6, 5 ** 12]
ary = (0..4).map{|i| p [0] * i + A([[5, 6 * (i + 1)], [1, -6 * (i + 1) - 1]], n)}
(0..n).each{|i|
  print "#{(0..4).inject(0){|s, j| s + a[j] * ary[j][i]}} = "
  (0..4).each{|j|
    print " + " if j > 0
    print "#{a[j]} * #{ary[j][i]}"
  }
  puts
}

出力結果
[1, 7, 35, 140, 490, 1541, 4480, 12195, 31465, 77525, 183626]
[0, 1, 13, 104, 637, 3276, 14808, 60541, 228124, 803010, 2667054, 8422715]
[0, 0, 1, 19, 209, 1710, 11495, 66862, 347339, 1645875, 7221520, 29668595, 115116233]
[0, 0, 0, 1, 25, 350, 3575, 29575, 209381, 1312075, 7443825, 38854075, 188836375, 862496902]
[0, 0, 0, 0, 1, 31, 527, 6448, 63240, 526443, 3852742, 25380847, 153068700, 855816380, 4479330091]
1575 = 1575 * 1 + 162500 * 0 + 4921875 * 0 + 58593750 * 0 + 244140625 * 0
173525 = 1575 * 7 + 162500 * 1 + 4921875 * 0 + 58593750 * 0 + 244140625 * 0
7089500 = 1575 * 35 + 162500 * 13 + 4921875 * 1 + 58593750 * 0 + 244140625 * 0
169229875 = 1575 * 140 + 162500 * 104 + 4921875 * 19 + 58593750 * 1 + 244140625 * 0
2841940500 = 1575 * 490 + 162500 * 637 + 4921875 * 209 + 58593750 * 25 + 244140625 * 1
37027355200 = 1575 * 1541 + 162500 * 3276 + 4921875 * 1710 + 58593750 * 350 + 244140625 * 31
397125074750 = 1575 * 4480 + 162500 * 14808 + 4921875 * 11495 + 58593750 * 3575 + 244140625 * 527
3646072432125 = 1575 * 12195 + 162500 * 60541 + 4921875 * 66862 + 58593750 * 29575 + 244140625 * 6448
29454549941750 = 1575 * 31465 + 162500 * 228124 + 4921875 * 347339 + 58593750 * 209381 + 244140625 * 63240
213636919820625 = 1575 * 77525 + 162500 * 803010 + 4921875 * 1645875 + 58593750 * 1312075 + 244140625 * 526443
1412749565173450 = 1575 * 183626 + 162500 * 2667054 + 4921875 * 7221520 + 58593750 * 7443825 + 244140625 * 3852742