2016年11月5日土曜日

161105(3)

Ruby


33…31型の素数(4)

末尾を9 に変えてみた。

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

出力結果
[1, 19, "prime"]
[2, 119, [[7, 1], [17, 1]]]
[3, 1119, [[3, 1], [373, 1]]]
[4, 11119, "prime"]
[5, 111119, "prime"]
[6, 1111119, [[3, 1], [370373, 1]]]
[7, 11111119, "prime"]
[8, 111111119, [[7, 1], [619, 1], [25643, 1]]]
[9, 1111111119, [[3, 2], [123456791, 1]]]
[10, 11111111119, [[43, 1], [258397933, 1]]]
[11, 111111111119, [[79, 1], [1406469761, 1]]]
[12, 1111111111119, [[3, 1], [797, 1], [2137, 1], [217457, 1]]]
[13, 11111111111119, [[107, 1], [27091, 1], [3833087, 1]]]
[14, 111111111111119, [[7, 1], [5827, 1], [2724045971, 1]]]
[15, 1111111111111119, [[3, 1], [29, 1], [138191, 1], [92418407, 1]]]
[1, 29, "prime"]
[2, 229, "prime"]
[3, 2229, [[3, 1], [743, 1]]]
[4, 22229, "prime"]
[5, 222229, [[7, 1], [53, 1], [599, 1]]]
[6, 2222229, [[3, 1], [71, 1], [10433, 1]]]
[7, 22222229, [[19, 1], [1169591, 1]]]
[8, 222222229, [[31, 1], [7168459, 1]]]
[9, 2222222229, [[3, 3], [443, 1], [185789, 1]]]
[10, 22222222229, [[145501, 1], [152729, 1]]]
[11, 222222222229, [[7, 1], [557, 1], [1087, 1], [52433, 1]]]
[12, 2222222222229, [[3, 1], [545497, 1], [1357919, 1]]]
[13, 22222222222229, "prime"]
[14, 222222222222229, [[17, 1], [47, 1], [278125434571, 1]]]
[15, 2222222222222229, [[3, 1], [23, 1], [352201, 1], [91442441, 1]]]
[1, 39, [[3, 1], [13, 1]]]
[2, 339, [[3, 1], [113, 1]]]
[3, 3339, [[3, 2], [7, 1], [53, 1]]]
[4, 33339, [[3, 1], [11113, 1]]]
[5, 333339, [[3, 1], [23, 1], [4831, 1]]]
[6, 3333339, [[3, 3], [123457, 1]]]
[7, 33333339, [[3, 1], [13, 1], [31, 1], [79, 1], [349, 1]]]
[8, 333333339, [[3, 1], [111111113, 1]]]
[9, 3333333339, [[3, 2], [7, 3], [1079797, 1]]]
[10, 33333333339, [[3, 1], [11111111113, 1]]]
[11, 333333333339, [[3, 1], [461, 1], [241021933, 1]]]
[12, 3333333333339, [[3, 2], [370370370371, 1]]]
[13, 33333333333339, [[3, 1], [13, 1], [95003, 1], [8996567, 1]]]
[14, 333333333333339, [[3, 1], [1163, 1], [95538358651, 1]]]
[15, 3333333333333339, [[3, 3], [7, 1], [17636684303351, 1]]]
[1, 49, [[7, 2]]]
[2, 449, "prime"]
[3, 4449, [[3, 1], [1483, 1]]]
[4, 44449, "prime"]
[5, 444449, "prime"]
[6, 4444449, [[3, 1], [1481483, 1]]]
[7, 44444449, [[7, 1], [269, 1], [23603, 1]]]
[8, 444444449, [[709, 1], [626861, 1]]]
[9, 4444444449, [[3, 2], [701, 1], [704461, 1]]]
[10, 44444444449, [[197, 1], [225606317, 1]]]
[11, 444444444449, [[28001, 1], [15872449, 1]]]
[12, 4444444444449, [[3, 1], [17, 1], [29, 1], [3005033431, 1]]]
[13, 44444444444449, [[7, 1], [61, 1], [104085349987, 1]]]
[14, 444444444444449, [[2087, 1], [24029, 1], [8862563, 1]]]
[15, 4444444444444449, [[3, 1], [19, 1], [77972709551657, 1]]]
[1, 59, "prime"]
[2, 559, [[13, 1], [43, 1]]]
[3, 5559, [[3, 1], [17, 1], [109, 1]]]
[4, 55559, [[7, 1], [7937, 1]]]
[5, 555559, [[431, 1], [1289, 1]]]
[6, 5555559, [[3, 1], [29, 1], [63857, 1]]]
[7, 55555559, "prime"]
[8, 555555559, [[13, 2], [3287311, 1]]]
[9, 5555555559, [[3, 3], [19, 1], [53, 1], [204331, 1]]]
[10, 55555555559, [[7, 1], [47, 1], [168861871, 1]]]
[11, 555555555559, "prime"]
[12, 5555555555559, [[3, 1], [257, 1], [7205649229, 1]]]
[13, 55555555555559, [[9013, 1], [17029, 1], [361967, 1]]]
[14, 555555555555559, [[13, 1], [42735042735043, 1]]]
[15, 5555555555555559, [[3, 1], [313, 1], [347, 1], [17050315823, 1]]]
[1, 69, [[3, 1], [23, 1]]]
[2, 669, [[3, 1], [223, 1]]]
[3, 6669, [[3, 3], [13, 1], [19, 1]]]
[4, 66669, [[3, 1], [71, 1], [313, 1]]]
[5, 666669, [[3, 1], [61, 1], [3643, 1]]]
[6, 6666669, [[3, 2], [17, 1], [43573, 1]]]
[7, 66666669, [[3, 1], [22222223, 1]]]
[8, 666666669, [[3, 1], [449, 1], [494927, 1]]]
[9, 6666666669, [[3, 2], [13, 1], [6353, 1], [8969, 1]]]
[10, 66666666669, [[3, 1], [22222222223, 1]]]
[11, 666666666669, [[3, 1], [787, 1], [1291, 1], [218719, 1]]]
[12, 6666666666669, [[3, 4], [431, 1], [10651, 1], [17929, 1]]]
[13, 66666666666669, [[3, 1], [401, 1], [55417013023, 1]]]
[14, 666666666666669, [[3, 1], [97, 1], [2290950744559, 1]]]
[15, 6666666666666669, [[3, 2], [13, 1], [56980056980057, 1]]]
[1, 79, "prime"]
[2, 779, [[19, 1], [41, 1]]]
[3, 7779, [[3, 1], [2593, 1]]]
[4, 77779, [[13, 1], [31, 1], [193, 1]]]
[5, 777779, [[113, 1], [6883, 1]]]
[6, 7777779, [[3, 1], [2592593, 1]]]
[7, 77777779, [[41, 1], [263, 1], [7213, 1]]]
[8, 777777779, [[3319, 1], [234341, 1]]]
[9, 7777777779, [[3, 2], [43, 1], [20097617, 1]]]
[10, 77777777779, [[13, 1], [229, 1], [26126227, 1]]]
[11, 777777777779, [[17, 1], [47, 1], [3823, 1], [254627, 1]]]
[12, 7777777777779, [[3, 1], [41, 1], [3167, 1], [19966519, 1]]]
[13, 77777777777779, [[5347, 1], [14546059057, 1]]]
[14, 777777777777779, [[23, 1], [79, 1], [1063, 1], [4817, 1], [83597, 1]]]
[15, 7777777777777779, [[3, 1], [103, 1], [617, 1], [40795464943, 1]]]
[1, 89, "prime"]
[2, 889, [[7, 1], [127, 1]]]
[3, 8889, [[3, 1], [2963, 1]]]
[4, 88889, [[103, 1], [863, 1]]]
[5, 888889, [[67, 1], [13267, 1]]]
[6, 8888889, [[3, 1], [2962963, 1]]]
[7, 88888889, [[251, 1], [354139, 1]]]
[8, 888888889, [[7, 1], [23, 1], [29, 1], [61, 1], [3121, 1]]]
[9, 8888888889, [[3, 4], [17, 2], [379721, 1]]]
[10, 88888888889, [[5081, 1], [17494369, 1]]]
[11, 888888888889, [[19, 1], [59, 1], [113, 1], [937, 1], [7489, 1]]]
[12, 8888888888889, [[3, 1], [4007, 1], [739446709, 1]]]
[13, 88888888888889, "prime"]
[14, 888888888888889, [[7, 2], [43, 1], [163, 1], [409, 1], [1423, 1], [4447, 1]]]
[15, 8888888888888889, [[3, 1], [83, 1], [48883, 1], [730281467, 1]]]

0 件のコメント:

コメントを投稿

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