2016年11月5日土曜日

161105(2)

Ruby


33…31型の素数(3)

末尾を7 に変えてみた。

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(7, 15)

出力結果
[1, 17, "prime"]
[2, 117, [[3, 2], [13, 1]]]
[3, 1117, "prime"]
[4, 11117, "prime"]
[5, 111117, [[3, 1], [37039, 1]]]
[6, 1111117, [[7, 1], [158731, 1]]]
[7, 11111117, "prime"]
[8, 111111117, [[3, 1], [13, 1], [1381, 1], [2063, 1]]]
[9, 1111111117, [[23, 1], [1069, 1], [45191, 1]]]
[10, 11111111117, [[1021, 1], [10882577, 1]]]
[11, 111111111117, [[3, 2], [71, 1], [173882803, 1]]]
[12, 1111111111117, [[7, 1], [31, 1], [131, 1], [39086471, 1]]]
[13, 11111111111117, [[419, 1], [26518164943, 1]]]
[14, 111111111111117, [[3, 1], [13, 1], [2849002849003, 1]]]
[15, 1111111111111117, [[19, 1], [7297, 1], [8014188319, 1]]]
[1, 27, [[3, 3]]]
[2, 227, "prime"]
[3, 2227, [[17, 1], [131, 1]]]
[4, 22227, [[3, 1], [31, 1], [239, 1]]]
[5, 222227, [[29, 1], [79, 1], [97, 1]]]
[6, 2222227, [[7, 1], [523, 1], [607, 1]]]
[7, 22222227, [[3, 1], [347, 1], [21347, 1]]]
[8, 222222227, "prime"]
[9, 2222222227, [[419, 1], [5303633, 1]]]
[10, 22222222227, [[3, 2], [2469135803, 1]]]
[11, 222222222227, [[19, 1], [23, 1], [239, 1], [2127689, 1]]]
[12, 2222222222227, [[7, 3], [4993, 1], [1297573, 1]]]
[13, 22222222222227, [[3, 1], [7407407407409, 1]]]
[14, 222222222222227, "prime"]
[15, 2222222222222227, [[17078023, 1], [130121749, 1]]]
[1, 37, "prime"]
[2, 337, "prime"]
[3, 3337, [[47, 1], [71, 1]]]
[4, 33337, [[17, 1], [37, 1], [53, 1]]]
[5, 333337, "prime"]
[6, 3333337, [[7, 1], [31, 1], [15361, 1]]]
[7, 33333337, [[37, 1], [163, 1], [5527, 1]]]
[8, 333333337, [[29, 1], [11494253, 1]]]
[9, 3333333337, [[191, 1], [17452007, 1]]]
[10, 33333333337, [[37, 2], [24348673, 1]]]
[11, 333333333337, [[269, 1], [5107, 1], [242639, 1]]]
[12, 3333333333337, [[7, 1], [168037, 1], [2833843, 1]]]
[13, 33333333333337, [[23, 1], [37, 1], [67, 1], [584620961, 1]]]
[14, 333333333333337, [[19, 1], [61, 1], [176651, 1], [1628093, 1]]]
[15, 3333333333333337, [[59, 1], [16993, 1], [3324732251, 1]]]
[1, 47, "prime"]
[2, 447, [[3, 1], [149, 1]]]
[3, 4447, "prime"]
[4, 44447, [[13, 2], [263, 1]]]
[5, 444447, [[3, 5], [31, 1], [59, 1]]]
[6, 4444447, [[7, 2], [90703, 1]]]
[7, 44444447, [[179, 1], [248293, 1]]]
[8, 444444447, [[3, 1], [17, 1], [19, 1], [458663, 1]]]
[9, 4444444447, "prime"]
[10, 44444444447, [[13, 1], [1361, 1], [2511979, 1]]]
[11, 444444444447, [[3, 1], [148148148149, 1]]]
[12, 4444444444447, [[7, 1], [24481, 1], [25935241, 1]]]
[13, 44444444444447, [[3571, 1], [12445937957, 1]]]
[14, 444444444444447, [[3, 2], [49382716049383, 1]]]
[15, 4444444444444447, [[29, 1], [153256704980843, 1]]]
[1, 57, [[3, 1], [19, 1]]]
[2, 557, "prime"]
[3, 5557, "prime"]
[4, 55557, [[3, 2], [6173, 1]]]
[5, 555557, "prime"]
[6, 5555557, [[7, 1], [43, 1], [18457, 1]]]
[7, 55555557, [[3, 1], [23, 1], [805153, 1]]]
[8, 555555557, [[31, 1], [47, 1], [381301, 1]]]
[9, 5555555557, "prime"]
[10, 55555555557, [[3, 1], [28211, 1], [656429, 1]]]
[11, 555555555557, [[40427, 1], [13742191, 1]]]
[12, 5555555555557, [[7, 1], [17, 1], [809, 1], [2617, 1], [22051, 1]]]
[13, 55555555555557, [[3, 2], [462191, 1], [13355603, 1]]]
[14, 555555555555557, "prime"]
[15, 5555555555555557, [[1259, 1], [2477, 1], [3677, 1], [484487, 1]]]
[1, 67, "prime"]
[2, 667, [[23, 1], [29, 1]]]
[3, 6667, [[59, 1], [113, 1]]]
[4, 66667, [[163, 1], [409, 1]]]
[5, 666667, "prime"]
[6, 6666667, [[7, 1], [952381, 1]]]
[7, 66666667, "prime"]
[8, 666666667, "prime"]
[9, 6666666667, [[19, 1], [1627, 1], [215659, 1]]]
[10, 66666666667, "prime"]
[11, 666666666667, [[43, 1], [2347, 1], [6605827, 1]]]
[12, 6666666666667, [[7, 1], [5981, 1], [159234401, 1]]]
[13, 66666666666667, [[17, 1], [1873, 1], [41161, 1], [50867, 1]]]
[14, 666666666666667, [[127, 1], [138563, 1], [37884167, 1]]]
[15, 6666666666666667, [[179, 1], [12713, 1], [2929595521, 1]]]
[1, 87, [[3, 1], [29, 1]]]
[2, 887, "prime"]
[3, 8887, "prime"]
[4, 88887, [[3, 1], [29629, 1]]]
[5, 888887, "prime"]
[6, 8888887, [[7, 1], [313, 1], [4057, 1]]]
[7, 88888887, [[3, 3], [227, 1], [14503, 1]]]
[8, 888888887, "prime"]
[9, 8888888887, [[67453, 1], [131779, 1]]]
[10, 88888888887, [[3, 1], [19, 1], [1559454191, 1]]]
[11, 888888888887, "prime"]
[12, 8888888888887, [[7, 1], [701, 1], [1811471141, 1]]]
[13, 88888888888887, [[3, 1], [151, 1], [2423, 1], [80983373, 1]]]
[14, 888888888888887, [[23, 1], [113, 1], [28393, 1], [12045641, 1]]]
[15, 8888888888888887, [[107, 1], [181, 1], [4787, 1], [95878603, 1]]]
[1, 97, "prime"]
[2, 997, "prime"]
[3, 9997, [[13, 1], [769, 1]]]
[4, 99997, [[19, 2], [277, 1]]]
[5, 999997, [[757, 1], [1321, 1]]]
[6, 9999997, [[7, 1], [1428571, 1]]]
[7, 99999997, [[1297, 1], [77101, 1]]]
[8, 999999997, [[71, 1], [2251, 1], [6257, 1]]]
[9, 9999999997, [[13, 1], [769230769, 1]]]
[10, 99999999997, [[17, 1], [5882352941, 1]]]
[11, 999999999997, [[5507, 1], [181587071, 1]]]
[12, 9999999999997, [[7, 2], [56527, 1], [3610339, 1]]]
[13, 99999999999997, [[839, 1], [119189511323, 1]]]
[14, 999999999999997, [[599, 1], [2131, 1], [3733, 1], [209861, 1]]]
[15, 9999999999999997, [[13, 1], [433, 1], [39323, 1], [45177491, 1]]]

0 件のコメント:

コメントを投稿