2016年11月3日木曜日

161103(2)

Ruby


33…31型の素数(1)

31 ←素数
331 ←素数
3331 ←素数
33331 ←素数
333331 ←素数
3333331 ←素数
33333331 ←素数
333333331 ←素数じゃない
というのを見て、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(1, 17)

出力結果
[1, 21, [[3, 1], [7, 1]]]
[2, 221, [[13, 1], [17, 1]]]
[3, 2221, "prime"]
[4, 22221, [[3, 3], [823, 1]]]
[5, 222221, [[359, 1], [619, 1]]]
[6, 2222221, [[19, 1], [116959, 1]]]
[7, 22222221, [[3, 1], [7, 1], [373, 1], [2837, 1]]]
[8, 222222221, [[13, 1], [17094017, 1]]]
[9, 2222222221, [[89, 1], [24968789, 1]]]
[10, 22222222221, [[3, 1], [56239, 1], [131713, 1]]]
[11, 222222222221, [[29, 1], [7662835249, 1]]]
[12, 2222222222221, [[163, 1], [181, 1], [75321907, 1]]]
[13, 22222222222221, [[3, 2], [7, 2], [109, 1], [443, 1], [521, 1], [2003, 1]]]
[14, 222222222222221, [[13, 1], [131, 1], [197003, 1], [662369, 1]]]
[15, 2222222222222221, [[67, 1], [1229, 1], [131321, 1], [205507, 1]]]
[16, 22222222222222221, [[3, 1], [23, 1], [211, 1], [239851, 1], [6363769, 1]]]
[17, 222222222222222221, "prime"]
[1, 31, "prime"]
[2, 331, "prime"]
[3, 3331, "prime"]
[4, 33331, "prime"]
[5, 333331, "prime"]
[6, 3333331, "prime"]
[7, 33333331, "prime"]
[8, 333333331, [[17, 1], [19607843, 1]]]
[9, 3333333331, [[673, 1], [4952947, 1]]]
[10, 33333333331, [[307, 1], [108577633, 1]]]
[11, 333333333331, [[19, 1], [83, 1], [211371803, 1]]]
[12, 3333333333331, [[523, 1], [3049, 1], [2090353, 1]]]
[13, 33333333333331, [[607, 1], [1511, 1], [1997, 1], [18199, 1]]]
[14, 333333333333331, [[181, 1], [1841620626151, 1]]]
[15, 3333333333333331, [[199, 1], [16750418760469, 1]]]
[16, 33333333333333331, [[31, 1], [1499, 1], [717324094199, 1]]]
[17, 333333333333333331, "prime"]
[1, 41, "prime"]
[2, 441, [[3, 2], [7, 2]]]
[3, 4441, "prime"]
[4, 44441, [[19, 1], [2339, 1]]]
[5, 444441, [[3, 1], [148147, 1]]]
[6, 4444441, [[41, 1], [108401, 1]]]
[7, 44444441, [[23, 1], [1932367, 1]]]
[8, 444444441, [[3, 1], [7, 1], [79, 1], [267899, 1]]]
[9, 4444444441, [[2503, 1], [1775647, 1]]]
[10, 44444444441, "prime"]
[11, 444444444441, [[3, 2], [41, 1], [293, 1], [1093, 1], [3761, 1]]]
[12, 4444444444441, [[83, 1], [503, 1], [106456309, 1]]]
[13, 44444444444441, [[852143, 1], [52156087, 1]]]
[14, 444444444444441, [[3, 1], [7, 1], [17, 1], [59, 1], [1753, 1], [12036919, 1]]]
[15, 4444444444444441, [[6823, 1], [62081, 1], [10492607, 1]]]
[16, 44444444444444441, [[29, 1], [41, 1], [37379684141669, 1]]]
[17, 444444444444444441, [[3, 1], [19141747, 1], [7739531201, 1]]]
[1, 51, [[3, 1], [17, 1]]]
[2, 551, [[19, 1], [29, 1]]]
[3, 5551, [[7, 1], [13, 1], [61, 1]]]
[4, 55551, [[3, 1], [18517, 1]]]
[5, 555551, [[31, 1], [17921, 1]]]
[6, 5555551, [[773, 1], [7187, 1]]]
[7, 55555551, [[3, 4], [47, 1], [14593, 1]]]
[8, 555555551, [[7417, 1], [74903, 1]]]
[9, 5555555551, [[7, 1], [13, 1], [131, 1], [227, 1], [2053, 1]]]
[10, 55555555551, [[3, 1], [23, 1], [181, 1], [4448359, 1]]]
[11, 555555555551, "prime"]
[12, 5555555555551, "prime"]
[13, 55555555555551, [[3, 1], [493807, 1], [37501531, 1]]]
[14, 555555555555551, [[229, 1], [2426006792819, 1]]]
[15, 5555555555555551, [[7, 1], [13, 1], [13513, 1], [31849, 1], [141853, 1]]]
[16, 55555555555555551, [[3, 2], [24071, 1], [256443002209, 1]]]
[17, 555555555555555551, [[17, 1], [3739, 1], [206177, 1], [42391901, 1]]]
[1, 61, "prime"]
[2, 661, "prime"]
[3, 6661, "prime"]
[4, 66661, [[7, 1], [89, 1], [107, 1]]]
[5, 666661, [[379, 1], [1759, 1]]]
[6, 6666661, [[113, 1], [58997, 1]]]
[7, 66666661, [[2011, 1], [33151, 1]]]
[8, 666666661, [[19, 1], [23, 1], [151, 1], [10103, 1]]]
[9, 6666666661, "prime"]
[10, 66666666661, [[7, 1], [9523809523, 1]]]
[11, 666666666661, [[47, 1], [79273, 1], [178931, 1]]]
[12, 6666666666661, [[134489, 1], [49570349, 1]]]
[13, 66666666666661, [[769, 1], [2861, 1], [30301529, 1]]]
[14, 666666666666661, [[13591, 1], [107201, 1], [457571, 1]]]
[15, 6666666666666661, [[547, 1], [12187690432663, 1]]]
[16, 66666666666666661, [[7, 1], [197, 1], [1512169, 1], [31970111, 1]]]
[17, 666666666666666661, "prime"]
[1, 71, "prime"]
[2, 771, [[3, 1], [257, 1]]]
[3, 7771, [[19, 1], [409, 1]]]
[4, 77771, [[83, 1], [937, 1]]]
[5, 777771, [[3, 2], [89, 1], [971, 1]]]
[6, 7777771, [[29, 1], [268199, 1]]]
[7, 77777771, [[17, 1], [4575163, 1]]]
[8, 777777771, [[3, 1], [259259257, 1]]]
[9, 7777777771, [[499, 1], [15586729, 1]]]
[10, 77777777771, [[151, 1], [283, 1], [1820087, 1]]]
[11, 777777777771, [[3, 1], [43, 1], [6029285099, 1]]]
[12, 7777777777771, "prime"]
[13, 77777777777771, [[23, 1], [60953, 1], [55479509, 1]]]
[14, 777777777777771, [[3, 2], [419, 1], [322139, 1], [640259, 1]]]
[15, 7777777777777771, [[997, 1], [7801181321743, 1]]]
[16, 77777777777777771, [[4143479, 1], [18771128749, 1]]]
[17, 777777777777777771, [[3, 1], [1013, 1], [255932141420789, 1]]]
[1, 81, [[3, 4]]]
[2, 881, "prime"]
[3, 8881, [[83, 1], [107, 1]]]
[4, 88881, [[3, 1], [13, 1], [43, 1], [53, 1]]]
[5, 888881, [[7, 1], [23, 1], [5521, 1]]]
[6, 8888881, [[59, 1], [150659, 1]]]
[7, 88888881, [[3, 1], [29629627, 1]]]
[8, 888888881, [[10903, 1], [81527, 1]]]
[9, 8888888881, [[31, 1], [286738351, 1]]]
[10, 88888888881, [[3, 2], [13, 1], [759734093, 1]]]
[11, 888888888881, [[7, 2], [18917, 1], [958957, 1]]]
[12, 8888888888881, [[17, 1], [2357, 1], [221839549, 1]]]
[13, 88888888888881, [[3, 1], [19, 1], [1559454191033, 1]]]
[14, 888888888888881, [[463, 1], [1919846412287, 1]]]
[15, 8888888888888881, [[429427, 1], [20699417803, 1]]]
[16, 88888888888888881, [[3, 1], [13, 1], [2279202279202279, 1]]]
[17, 888888888888888881, [[7, 1], [47, 1], [53, 1], [181, 1], [461, 1], [541, 1], [971, 1], [1163, 1]]]
[1, 91, [[7, 1], [13, 1]]]
[2, 991, "prime"]
[3, 9991, [[97, 1], [103, 1]]]
[4, 99991, "prime"]
[5, 999991, [[17, 1], [59, 1], [997, 1]]]
[6, 9999991, "prime"]
[7, 99999991, [[7, 1], [13, 1], [769, 1], [1429, 1]]]
[8, 999999991, [[67, 1], [14925373, 1]]]
[9, 9999999991, [[19, 2], [277, 1], [100003, 1]]]
[10, 99999999991, [[83, 1], [1289, 1], [934693, 1]]]
[11, 999999999991, [[757, 1], [1321, 1], [1000003, 1]]]
[12, 9999999999991, [[31, 1], [3391, 1], [95128471, 1]]]
[13, 99999999999991, [[7, 1], [13, 1], [769231, 1], [1428571, 1]]]
[14, 999999999999991, [[653, 1], [718321, 1], [2131907, 1]]]
[15, 9999999999999991, [[643, 1], [1297, 1], [77101, 1], [155521, 1]]]
[16, 99999999999999991, [[43, 1], [19387, 1], [119955712351, 1]]]
[17, 999999999999999991, [[23, 1], [71, 1], [307, 1], [2251, 1], [6257, 1], [141623, 1]]]

0 件のコメント:

コメントを投稿

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