末尾を3 に変えてみた。
require 'prime'
def f(m, n)
(1..9).each{|i|
if i != m
(1..n).each{|j|
k = ([i] * j + [m]).join.to_i
if k.prime?
p [j, k, 'prime']
else
p [j, k, k.prime_division]
end
}
end
}
end
f(3, 15)
出力結果
[1, 13, "prime"]
[2, 113, "prime"]
[3, 1113, [[3, 1], [7, 1], [53, 1]]]
[4, 11113, "prime"]
[5, 111113, [[23, 1], [4831, 1]]]
[6, 1111113, [[3, 2], [123457, 1]]]
[7, 11111113, [[13, 1], [31, 1], [79, 1], [349, 1]]]
[8, 111111113, "prime"]
[9, 1111111113, [[3, 1], [7, 3], [1079797, 1]]]
[10, 11111111113, "prime"]
[11, 111111111113, [[461, 1], [241021933, 1]]]
[12, 1111111111113, [[3, 1], [370370370371, 1]]]
[13, 11111111111113, [[13, 1], [95003, 1], [8996567, 1]]]
[14, 111111111111113, [[1163, 1], [95538358651, 1]]]
[15, 1111111111111113, [[3, 2], [7, 1], [17636684303351, 1]]]
[1, 23, "prime"]
[2, 223, "prime"]
[3, 2223, [[3, 2], [13, 1], [19, 1]]]
[4, 22223, [[71, 1], [313, 1]]]
[5, 222223, [[61, 1], [3643, 1]]]
[6, 2222223, [[3, 1], [17, 1], [43573, 1]]]
[7, 22222223, "prime"]
[8, 222222223, [[449, 1], [494927, 1]]]
[9, 2222222223, [[3, 1], [13, 1], [6353, 1], [8969, 1]]]
[10, 22222222223, "prime"]
[11, 222222222223, [[787, 1], [1291, 1], [218719, 1]]]
[12, 2222222222223, [[3, 3], [431, 1], [10651, 1], [17929, 1]]]
[13, 22222222222223, [[401, 1], [55417013023, 1]]]
[14, 222222222222223, [[97, 1], [2290950744559, 1]]]
[15, 2222222222222223, [[3, 1], [13, 1], [56980056980057, 1]]]
[1, 43, "prime"]
[2, 443, "prime"]
[3, 4443, [[3, 1], [1481, 1]]]
[4, 44443, [[7, 2], [907, 1]]]
[5, 444443, "prime"]
[6, 4444443, [[3, 3], [97, 1], [1697, 1]]]
[7, 44444443, [[17, 2], [29, 1], [5303, 1]]]
[8, 444444443, "prime"]
[9, 4444444443, [[3, 1], [1481481481, 1]]]
[10, 44444444443, [[7, 1], [6349206349, 1]]]
[11, 444444444443, "prime"]
[12, 4444444444443, [[3, 1], [1481481481481, 1]]]
[13, 44444444444443, [[2833, 1], [15688120171, 1]]]
[14, 444444444444443, [[19, 1], [6229, 1], [3755307893, 1]]]
[15, 4444444444444443, [[3, 2], [5050471, 1], [97778437, 1]]]
[1, 53, "prime"]
[2, 553, [[7, 1], [79, 1]]]
[3, 5553, [[3, 2], [617, 1]]]
[4, 55553, [[73, 1], [761, 1]]]
[5, 555553, [[29, 1], [19157, 1]]]
[6, 5555553, [[3, 1], [1851851, 1]]]
[7, 55555553, "prime"]
[8, 555555553, [[7, 1], [6113, 1], [12983, 1]]]
[9, 5555555553, [[3, 1], [1851851851, 1]]]
[10, 55555555553, [[191, 1], [290866783, 1]]]
[11, 555555555553, [[971, 1], [17443, 1], [32801, 1]]]
[12, 5555555555553, [[3, 2], [73, 1], [409, 1], [20674681, 1]]]
[13, 55555555555553, [[17, 1], [19, 1], [171998624011, 1]]]
[14, 555555555555553, [[7, 1], [53, 1], [1497454327643, 1]]]
[15, 5555555555555553, [[3, 1], [79, 1], [2198701, 1], [10661369, 1]]]
[1, 63, [[3, 2], [7, 1]]]
[2, 663, [[3, 1], [13, 1], [17, 1]]]
[3, 6663, [[3, 1], [2221, 1]]]
[4, 66663, [[3, 4], [823, 1]]]
[5, 666663, [[3, 1], [359, 1], [619, 1]]]
[6, 6666663, [[3, 1], [19, 1], [116959, 1]]]
[7, 66666663, [[3, 2], [7, 1], [373, 1], [2837, 1]]]
[8, 666666663, [[3, 1], [13, 1], [17094017, 1]]]
[9, 6666666663, [[3, 1], [89, 1], [24968789, 1]]]
[10, 66666666663, [[3, 2], [56239, 1], [131713, 1]]]
[11, 666666666663, [[3, 1], [29, 1], [7662835249, 1]]]
[12, 6666666666663, [[3, 1], [163, 1], [181, 1], [75321907, 1]]]
[13, 66666666666663, [[3, 3], [7, 2], [109, 1], [443, 1], [521, 1], [2003, 1]]]
[14, 666666666666663, [[3, 1], [13, 1], [131, 1], [197003, 1], [662369, 1]]]
[15, 6666666666666663, [[3, 1], [67, 1], [1229, 1], [131321, 1], [205507, 1]]]
[1, 73, "prime"]
[2, 773, "prime"]
[3, 7773, [[3, 1], [2591, 1]]]
[4, 77773, "prime"]
[5, 777773, [[709, 1], [1097, 1]]]
[6, 7777773, [[3, 2], [233, 1], [3709, 1]]]
[7, 77777773, [[19, 1], [4093567, 1]]]
[8, 777777773, "prime"]
[9, 7777777773, [[3, 1], [23, 1], [73, 1], [1544129, 1]]]
[10, 77777777773, [[29, 1], [53, 1], [1777, 1], [28477, 1]]]
[11, 777777777773, "prime"]
[12, 7777777777773, [[3, 1], [17, 1], [601, 1], [3557, 1], [71339, 1]]]
[13, 77777777777773, [[2579, 1], [30158114687, 1]]]
[14, 777777777777773, "prime"]
[15, 7777777777777773, [[3, 3], [288065843621399, 1]]]
[1, 83, "prime"]
[2, 883, "prime"]
[3, 8883, [[3, 3], [7, 1], [47, 1]]]
[4, 88883, "prime"]
[5, 888883, [[397, 1], [2239, 1]]]
[6, 8888883, [[3, 1], [2962961, 1]]]
[7, 88888883, "prime"]
[8, 888888883, "prime"]
[9, 8888888883, [[3, 1], [7, 1], [19, 1], [2687, 1], [8291, 1]]]
[10, 88888888883, [[59, 1], [1506591337, 1]]]
[11, 888888888883, [[17, 1], [349, 1], [149821151, 1]]]
[12, 8888888888883, [[3, 2], [3779, 1], [261353353, 1]]]
[13, 88888888888883, [[1738543, 1], [51128381, 1]]]
[14, 888888888888883, "prime"]
[15, 8888888888888883, [[3, 1], [7, 1], [3096389, 1], [136701307, 1]]]
[1, 93, [[3, 1], [31, 1]]]
[2, 993, [[3, 1], [331, 1]]]
[3, 9993, [[3, 1], [3331, 1]]]
[4, 99993, [[3, 1], [33331, 1]]]
[5, 999993, [[3, 1], [333331, 1]]]
[6, 9999993, [[3, 1], [3333331, 1]]]
[7, 99999993, [[3, 1], [33333331, 1]]]
[8, 999999993, [[3, 1], [17, 1], [19607843, 1]]]
[9, 9999999993, [[3, 1], [673, 1], [4952947, 1]]]
[10, 99999999993, [[3, 1], [307, 1], [108577633, 1]]]
[11, 999999999993, [[3, 1], [19, 1], [83, 1], [211371803, 1]]]
[12, 9999999999993, [[3, 1], [523, 1], [3049, 1], [2090353, 1]]]
[13, 99999999999993, [[3, 1], [607, 1], [1511, 1], [1997, 1], [18199, 1]]]
[14, 999999999999993, [[3, 1], [181, 1], [1841620626151, 1]]]
[15, 9999999999999993, [[3, 1], [199, 1], [16750418760469, 1]]]
0 件のコメント:
コメントを投稿
注: コメントを投稿できるのは、このブログのメンバーだけです。