こんにちは|こんばんは。カエルのアイコンで活動しております @kyamaz です。
はじめに
以前のエントリ名前のついた素数コレクション 〜Haskellを添えて〜で、名前のついた素数について取り上げました。そのエントリでプログラムを紹介しなかった『そのほかの素数』の中から、ラッキー素数(幸運素数)とハッピー素数について詳細を取り上げたいと思います。
なんだか幸せになりそうな名前がついていますが、素数というよりはそれぞれ、ラッキー数とハッピー数という数列があり、その数列のなかで素数のものを言います。本稿では、『ラッキー数』『ハッピー数』について解説し、ハッピーでラッキーな数列とその中から素数であるハッピー&ラッキー素数をプログラムで求めてみましょう。
ラッキー数
素数列を得る方法のエラトステネスの篩(ふるい)に似た『ウラムの篩』で残った奇数列を「ウラムのラッキー数(幸運数)」といいます。
ウラムの篩
ウラムの篩は次の手順で進めます。
1)1から始まる自然数列から、まずは1を残します
2)次に2を残して、2番目ごとの数を消します(これで奇数が残ります)
3)次に3を残して、上の奇数列の3番目個ごとの数($5,11,17,\dots$)を消します
4)次に7を残して、上の奇数列の7番目個ごとの数($19,\dots$)を消します
5)このあと同様に、残っているはじめの数$k$を残して、$k$番目ごとの数を消していきます
ラッキー数列を返すプログラムは次のようになります。
:{
luckyNumbers = 1 : sieve 2 [1,3..] where
sieve k xs = z : sieve (k+1) (lucky xs) where
z = xs !! (k-1)
lucky ws = us ++ lucky vs where
(us, _:vs) = splitAt (z-1) ws
:}
出力のためのchunk
関数を使って、100個のラッキー数を出力してみましょう。(chunk
関数はこの後でも使います)
ghci> chunk n xs | xs == [] = [] | otherwise = take n xs : chunk n (drop n xs)
ghci> mapM_ print $ chunk 10 $ take 100 luckyNumbers
[1,3,7,9,13,15,21,25,31,33]
[37,43,49,51,63,67,69,73,75,79]
[87,93,99,105,111,115,127,129,133,135]
[141,151,159,163,169,171,189,193,195,201]
[205,211,219,223,231,235,237,241,259,261]
[267,273,283,285,289,297,303,307,319,321]
[327,331,339,349,357,361,367,385,391,393]
[399,409,415,421,427,429,433,451,463,475]
[477,483,487,489,495,511,517,519,529,535]
[537,541,553,559,577,579,583,591,601,613]
ハッピー数
各桁を1桁に分解して二乗和を取り、新しくできた数についても同じ処理を繰り返し行って、最終的に$1$となる数を『ハッピー数』といいます。
定義から、ある数がハッピー数なら、桁の順番を入れ替えた数もハッピー数となります。例えば、$23$はハッピー数なので、$32$はハッピー数です。また、途中に$0$を挿入した数もハッピー数となります。
ハッピー数列を返すプログラムは次のようになります。
import Data.Char (digitToInt)
import Data.Set (member, insert, empty)
isHappy = h empty where h _ 1 = True; h s n | n `member` s = False | otherwise = h (insert n s) (f n) where f = sum . fmap ((^ 2) . toInteger . digitToInt) . show
happyNumber = filter isHappy [1..]
次に、100個のハッピー数を出力してみましょう。
ghci> chunk n xs | xs == [] = [] | otherwise = take n xs : chunk n (drop n xs)
ghci> mapM_ print $ chunk 10 $ take 100 happyNumber
[1,7,10,13,19,23,28,31,32,44]
[49,68,70,79,82,86,91,94,97,100]
[103,109,129,130,133,139,167,176,188,190]
[192,193,203,208,219,226,230,236,239,262]
[263,280,291,293,301,302,310,313,319,320]
[326,329,331,338,356,362,365,367,368,376]
[379,383,386,391,392,397,404,409,440,446]
[464,469,478,487,490,496,536,556,563,565]
[566,608,617,622,623,632,635,637,638,644]
[649,653,655,656,665,671,673,680,683,694]
【ハッピー数に関するトリビア】
- $44488$から続く5つの数は全てハッピー数1
- $7899999999999959999999996$から続く7つの数は全てハッピー数1
- 素数番目の素数のことを超素数と呼びますが、ハッピー数番目のハッピー数のことを超ハッピー数と呼びましょう。そのときの超ハッピー数列は次のようになります。2
超ハッピー数:
$1,28,44,70,97,129,176,192,193,293,319,409,446,563,608, \dots$
ハッピー&ラッキー数
ハッピー数かつラッキー数であるような自然数を『ハッピー&ラッキー数』と呼びましょう。
前述のプログラムを使えば、次のように求められます。
happyLucky = [x|x<-luckyNumbers, isHappy (toInteger x)]
ghci> mapM_ print $ chunk 10 $ take 100 happyLucky
[1,7,13,31,49,79,129,133,193,219]
[319,331,367,391,409,487,655,673,739,931]
[937,1009,1029,1039,1093,1209,1233,1251,1275,1281]
[1285,1303,1309,1323,1339,1533,1575,1587,1599,1663]
[1771,1857,1933,1959,1995,2019,2115,2121,2133,2211]
[2221,2257,2511,2527,2545,2557,2571,2575,2715,2725]
[2755,2815,2845,2851,2899,2901,3031,3091,3097,3109]
[3123,3133,3153,3213,3301,3313,3351,3355,3465,3607]
[3661,3709,3763,3789,3879,3897,3931,4069,4255,4257]
[4285,4287,4363,4441,4455,4609,4653,4663,4725,4741]
素数判定関数is_prime'
を使って、その中から素数のものを求めましょう。
exp_mod a n = iter a (n-1) n where iter a n base | n == 1 = a | even n = (iter a (n `div` 2) base) ^ 2 `mod` base | otherwise = a * (iter a ((n-1) `div` 2) base) ^ 2 `mod` base
is_prime' n | n<=1 = False | otherwise = and $ map (\a -> test n a) $ takeWhile (<n) [2,3,5,7,11,13,17,19] where test n a | gcd n a == 1 = (1 == exp_mod a n) | otherwise = False
次のようになります。
(※ラッキー数の計算には時間を要します。後述の通り、あらかじめラッキー数を求めておくと良い)
ghci> mapM_ print $ chunk 10 $ take 100 $ filter is_prime' luckyHappy
[7,13,31,79,193,331,367,409,487,673]
[739,937,1009,1039,1093,1303,1663,1933,2221,2557]
[2851,3109,3301,3313,3607,3709,3931,4363,4441,4663]
[5527,5569,6163,6367,6373,6661,6733,6763,7603,8233]
[10009,10903,11113,11197,11491,13009,13177,13309,14281,14347]
[14407,14437,14449,14461,15121,16417,17713,18253,18523,18757]
[19333,19963,20899,21787,21841,22381,22651,22921,23893,24181]
[25057,25237,25561,25621,25657,26251,27283,27793,28123,28351]
[28393,28513,28771,28837,28933,30013,30103,30313,30367,30643]
[31033,31039,31699,32803,33091,33289,34603,36037,36067,37117]
おわりに
ウラムの篩のプログラムはそれなりに計算時間がかかります。$40000$までの計算結果を折りたたんで掲載しておきます。このなかに、連続する3つの素数が連続する3つのラッキー数となっているような $3301,3307,3313$ が見つかったりします。眺めて研究してみてはいかがでしょうか。
$40000$までのラッキー数
ghci> mapM_ print $ chunk 10 $ takeWhile (<40000) luckyNumbers
[1,3,7,9,13,15,21,25,31,33]
[37,43,49,51,63,67,69,73,75,79]
[87,93,99,105,111,115,127,129,133,135]
[141,151,159,163,169,171,189,193,195,201]
[205,211,219,223,231,235,237,241,259,261]
[267,273,283,285,289,297,303,307,319,321]
[327,331,339,349,357,361,367,385,391,393]
[399,409,415,421,427,429,433,451,463,475]
[477,483,487,489,495,511,517,519,529,535]
[537,541,553,559,577,579,583,591,601,613]
[615,619,621,631,639,643,645,651,655,673]
[679,685,693,699,717,723,727,729,735,739]
[741,745,769,777,781,787,801,805,819,823]
[831,841,855,867,873,883,885,895,897,903]
[925,927,931,933,937,957,961,975,979,981]
[991,993,997,1009,1011,1021,1023,1029,1039,1041]
[1053,1057,1087,1093,1095,1101,1105,1107,1117,1123]
[1147,1155,1167,1179,1183,1189,1197,1201,1203,1209]
[1219,1231,1233,1245,1249,1251,1261,1263,1275,1281]
[1285,1291,1303,1309,1323,1329,1339,1357,1365,1369]
[1387,1389,1395,1401,1417,1419,1435,1441,1455,1459]
[1471,1473,1485,1491,1495,1497,1501,1503,1519,1533]
[1543,1545,1563,1567,1575,1579,1585,1587,1597,1599]
[1611,1639,1641,1645,1659,1663,1675,1693,1701,1705]
[1711,1723,1731,1737,1749,1765,1767,1771,1773,1777]
[1797,1801,1809,1819,1827,1831,1833,1839,1857,1869]
[1879,1893,1899,1915,1921,1923,1933,1941,1945,1959]
[1963,1965,1977,1983,1987,1995,2001,2019,2023,2031]
[2053,2059,2065,2067,2079,2083,2085,2095,2113,2115]
[2121,2125,2127,2133,2163,2173,2187,2209,2211,2215]
[2217,2221,2239,2251,2253,2257,2271,2277,2281,2283]
[2301,2311,2317,2323,2335,2343,2355,2365,2379,2395]
[2403,2407,2409,2415,2419,2427,2439,2445,2461,2467]
[2473,2479,2491,2493,2505,2511,2523,2527,2545,2557]
[2563,2571,2575,2587,2589,2593,2599,2607,2625,2635]
[2647,2649,2653,2661,2667,2671,2689,2697,2715,2725]
[2755,2763,2773,2781,2785,2787,2797,2815,2817,2821]
[2823,2827,2835,2841,2845,2851,2877,2887,2899,2901]
[2905,2913,2923,2943,2953,2961,2971,2973,2977,2983]
[3003,3007,3027,3031,3037,3039,3049,3055,3073,3075]
[3091,3097,3099,3109,3111,3121,3123,3133,3153,3163]
[3171,3175,3183,3187,3199,3213,3223,3229,3235,3243]
[3259,3261,3289,3297,3301,3307,3313,3325,3339,3351]
[3355,3363,3381,3403,3405,3409,3411,3427,3433,3439]
[3451,3453,3465,3477,3481,3487,3489,3495,3499,3507]
[3559,3565,3571,3579,3595,3597,3603,3607,3613,3621]
[3625,3633,3655,3661,3663,3669,3675,3685,3687,3697]
[3709,3717,3721,3727,3747,3753,3763,3771,3781,3789]
[3793,3795,3811,3843,3847,3849,3865,3873,3879,3889]
[3891,3897,3909,3915,3931,3943,3951,3955,3969,3975]
[3981,3991,3999,4003,4015,4023,4033,4035,4041,4045]
[4063,4069,4081,4095,4105,4107,4129,4131,4161,4165]
[4173,4179,4189,4195,4201,4203,4207,4227,4237,4251]
[4255,4257,4263,4269,4285,4287,4315,4321,4329,4335]
[4363,4377,4383,4389,4399,4413,4431,4441,4443,4455]
[4461,4465,4483,4485,4495,4509,4519,4521,4539,4551]
[4561,4567,4569,4573,4587,4609,4611,4621,4623,4629]
[4645,4647,4653,4663,4671,4675,4695,4699,4713,4717]
[4725,4741,4761,4767,4773,4797,4801,4809,4813,4819]
[4833,4837,4839,4843,4851,4863,4867,4881,4887,4893]
[4929,4951,4963,4965,4969,4977,4987,4989,4993,4999]
[5001,5007,5019,5029,5041,5043,5049,5053,5089,5103]
[5127,5137,5139,5149,5151,5157,5169,5179,5181,5191]
[5211,5217,5229,5233,5235,5253,5259,5277,5283,5293]
[5295,5299,5325,5335,5341,5343,5371,5377,5379,5385]
[5409,5419,5427,5433,5449,5455,5463,5473,5487,5491]
[5503,5515,5527,5547,5551,5559,5569,5577,5587,5589]
[5593,5599,5613,5617,5637,5641,5649,5655,5661,5671]
[5673,5679,5691,5701,5707,5713,5719,5737,5755,5763]
[5767,5769,5803,5809,5817,5827,5833,5839,5851,5869]
[5883,5889,5893,5901,5905,5911,5913,5923,5959,5965]
[5967,5971,5973,5977,5991,5997,6009,6019,6031,6049]
[6055,6061,6079,6093,6111,6115,6123,6141,6147,6159]
[6163,6175,6177,6195,6211,6229,6237,6243,6249,6253]
[6271,6273,6279,6301,6309,6331,6345,6351,6355,6363]
[6367,6369,6373,6379,6385,6399,6411,6415,6427,6433]
[6435,6447,6463,6471,6475,6477,6501,6505,6523,6531]
[6535,6541,6553,6559,6567,6573,6601,6621,6625,6631]
[6661,6663,6667,6669,6679,6687,6693,6715,6723,6733]
[6741,6745,6747,6753,6757,6763,6765,6783,6787,6789]
[6841,6849,6867,6871,6883,6891,6909,6915,6921,6931]
[6933,6937,6951,6981,6985,6999,7003,7009,7035,7041]
[7045,7047,7069,7077,7081,7087,7101,7111,7129,7135]
[7153,7167,7171,7173,7183,7191,7195,7197,7207,7215]
[7231,7233,7237,7245,7249,7279,7293,7299,7311,7321]
[7333,7339,7341,7345,7357,7359,7371,7377,7395,7401]
[7405,7419,7435,7437,7443,7447,7459,7471,7489,7501]
[7503,7507,7531,7533,7549,7551,7563,7567,7575,7585]
[7591,7593,7603,7609,7629,7633,7639,7645,7677,7687]
[7689,7701,7711,7717,7737,7755,7779,7791,7795,7801]
[7803,7813,7827,7833,7837,7855,7881,7885,7897,7899]
[7909,7917,7921,7929,7939,7947,7951,7963,7969,7971]
[8001,8005,8007,8013,8037,8047,8071,8073,8085,8089]
[8107,8109,8127,8131,8139,8151,8161,8169,8173,8175]
[8191,8193,8221,8223,8227,8233,8253,8257,8263,8269]
[8283,8289,8299,8325,8331,8347,8359,8365,8367,8379]
[8409,8413,8421,8445,8449,8467,8473,8475,8479,8487]
[8493,8515,8535,8539,8551,8553,8575,8577,8583,8589]
[8601,8605,8611,8617,8635,8637,8641,8647,8655,8661]
[8673,8683,8719,8757,8769,8773,8787,8793,8805,8809]
[8827,8829,8833,8835,8841,8869,8871,8895,8913,8931]
[8937,8947,8955,8961,8977,8979,8989,8995,8997,9009]
[9031,9033,9061,9063,9073,9075,9081,9085,9115,9117]
[9121,9123,9135,9139,9145,9151,9177,9181,9211,9213]
[9223,9231,9235,9249,9253,9267,9273,9277,9285,9291]
[9303,9315,9331,9339,9349,9373,9387,9399,9403,9409]
[9421,9423,9429,9441,9451,9457,9471,9475,9481,9483]
[9487,9501,9535,9537,9543,9547,9549,9555,9561,9567]
[9613,9621,9625,9631,9643,9649,9661,9663,9675,9687]
[9691,9703,9727,9733,9751,9753,9775,9787,9789,9795]
[9801,9807,9811,9813,9837,9841,9883,9895,9915,9927]
[9937,9957,9961,9979,9985,9987,9997,9999,10003,10009]
[10017,10041,10051,10059,10069,10071,10083,10087,10089,10095]
[10111,10117,10125,10131,10143,10147,10149,10153,10173,10191]
[10195,10197,10221,10239,10255,10261,10275,10279,10291,10311]
[10315,10317,10321,10341,10363,10365,10387,10399,10411,10417]
[10431,10441,10443,10459,10461,10471,10501,10507,10509,10525]
[10531,10533,10555,10563,10569,10575,10585,10587,10597,10599]
[10605,10609,10635,10651,10653,10659,10671,10683,10723,10725]
[10731,10747,10753,10755,10759,10773,10785,10789,10797,10809]
[10843,10849,10873,10881,10891,10903,10909,10911,10921,10923]
[10945,10953,10965,10975,10977,11005,11011,11017,11047,11055]
[11059,11073,11077,11089,11091,11097,11113,11137,11157,11163]
[11173,11181,11193,11197,11205,11217,11223,11227,11239,11245]
[11247,11259,11263,11269,11283,11289,11301,11323,11341,11343]
[11371,11373,11377,11389,11391,11395,11407,11419,11425,11427]
[11437,11439,11475,11479,11487,11491,11521,11529,11535,11539]
[11541,11577,11581,11583,11599,11617,11623,11629,11641,11643]
[11659,11667,11677,11679,11707,11721,11725,11731,11769,11781]
[11797,11803,11811,11815,11823,11827,11833,11835,11845,11847]
[11853,11865,11877,11887,11911,11923,11929,11943,11953,11959]
[11961,11991,11995,12007,12015,12025,12049,12057,12063,12069]
[12079,12097,12103,12117,12121,12133,12139,12141,12151,12159]
[12163,12165,12193,12201,12207,12223,12237,12243,12265,12267]
[12285,12295,12301,12307,12315,12319,12321,12333,12337,12357]
[12363,12373,12379,12391,12399,12411,12417,12427,12435,12457]
[12481,12487,12495,12499,12519,12543,12547,12553,12567,12579]
[12589,12607,12609,12621,12631,12645,12649,12651,12673,12679]
[12699,12709,12711,12729,12735,12741,12759,12763,12777,12781]
[12799,12801,12813,12819,12861,12867,12877,12885,12903,12907]
[12925,12937,12951,12957,12961,12969,12991,12999,13009,13011]
[13021,13027,13029,13053,13057,13063,13077,13083,13113,13117]
[13119,13125,13129,13135,13141,13167,13177,13179,13203,13209]
[13215,13219,13243,13245,13267,13273,13279,13281,13285,13293]
[13309,13317,13323,13327,13335,13345,13347,13359,13363,13371]
[13387,13419,13441,13443,13465,13473,13485,13489,13513,13515]
[13519,13527,13531,13533,13537,13551,13567,13575,13581,13587]
[13599,13609,13633,13657,13677,13681,13693,13695,13707,13723]
[13725,13737,13741,13743,13759,13801,13803,13821,13831,13833]
[13849,13851,13861,13873,13893,13897,13929,13947,13953,13957]
[13995,14007,14017,14031,14035,14037,14041,14049,14053,14059]
[14073,14079,14091,14095,14113,14115,14119,14137,14163,14179]
[14181,14185,14199,14205,14209,14211,14217,14229,14245,14247]
[14253,14281,14287,14293,14307,14313,14317,14331,14347,14349]
[14353,14367,14395,14407,14419,14427,14437,14439,14443,14449]
[14457,14461,14473,14491,14493,14505,14521,14523,14539,14541]
[14565,14587,14595,14599,14601,14607,14625,14661,14667,14689]
[14691,14713,14715,14721,14731,14749,14751,14755,14775,14779]
[14785,14793,14797,14817,14841,14875,14881,14883,14899,14905]
[14919,14923,14931,14935,14943,14947,14973,14977,14997,15003]
[15007,15009,15025,15031,15049,15057,15063,15069,15073,15081]
[15103,15109,15121,15129,15133,15141,15165,15169,15175,15183]
[15187,15189,15193,15205,15213,15217,15229,15231,15235,15237]
[15247,15255,15259,15261,15271,15291,15301,15313,15333,15355]
[15379,15381,15385,15397,15417,15445,15457,15469,15471,15481]
[15487,15489,15511,15519,15523,15531,15543,15547,15567,15573]
[15577,15585,15597,15609,15645,15655,15661,15673,15675,15693]
[15697,15717,15735,15763,15771,15783,15793,15805,15817,15819]
[15835,15843,15847,15855,15879,15883,15891,15901,15907,15919]
[15927,15939,15955,15969,15975,15981,15993,16003,16009,16023]
[16045,16047,16053,16057,16077,16081,16095,16101,16135,16153]
[16191,16195,16197,16203,16213,16227,16237,16245,16255,16267]
[16275,16279,16287,16297,16309,16329,16333,16341,16353,16359]
[16365,16381,16387,16389,16393,16395,16413,16417,16429,16431]
[16447,16449,16467,16473,16479,16491,16507,16521,16539,16557]
[16573,16591,16611,16615,16617,16621,16635,16639,16657,16665]
[16677,16701,16707,16725,16747,16765,16771,16773,16791,16795]
[16825,16827,16845,16863,16867,16893,16915,16917,16921,16933]
[16939,16947,16953,16957,16959,16969,16971,16981,16995,17001]
[17011,17017,17019,17035,17047,17053,17061,17083,17085,17103]
[17115,17119,17125,17127,17151,17157,17173,17181,17209,17211]
[17215,17221,17223,17229,17251,17253,17283,17287,17305,17313]
[17329,17335,17341,17355,17359,17367,17389,17391,17401,17409]
[17431,17433,17455,17463,17467,17473,17485,17497,17517,17527]
[17535,17545,17547,17563,17565,17581,17589,17619,17625,17671]
[17677,17689,17695,17703,17713,17725,17733,17737,17749,17767]
[17769,17775,17781,17787,17797,17811,17829,17851,17875,17883]
[17893,17913,17925,17935,17943,17947,17965,17977,17991,17997]
[18001,18007,18019,18025,18043,18049,18055,18067,18085,18087]
[18123,18127,18145,18147,18151,18153,18169,18175,18181,18187]
[18189,18195,18207,18211,18237,18253,18261,18279,18283,18285]
[18295,18303,18315,18333,18375,18381,18397,18399,18403,18409]
[18441,18445,18451,18459,18465,18469,18475,18493,18495,18501]
[18513,18523,18535,18543,18589,18591,18597,18615,18619,18621]
[18633,18639,18655,18661,18681,18693,18715,18717,18723,18745]
[18747,18757,18759,18765,18775,18777,18783,18787,18817,18819]
[18825,18837,18849,18853,18871,18873,18879,18915,18937,18943]
[18951,18967,18969,18975,18979,18987,19009,19015,19017,19033]
[19051,19081,19113,19119,19125,19131,19153,19155,19159,19161]
[19173,19195,19197,19207,19225,19237,19261,19263,19269,19285]
[19309,19323,19327,19329,19333,19341,19347,19351,19357,19363]
[19365,19371,19389,19395,19405,19411,19417,19435,19455,19467]
[19477,19479,19503,19521,19533,19543,19551,19579,19581,19603]
[19609,19615,19627,19629,19657,19659,19687,19693,19705,19707]
[19711,19719,19723,19725,19731,19735,19755,19767,19771,19773]
[19783,19791,19807,19825,19851,19861,19869,19875,19893,19917]
[19921,19929,19939,19963,19981,19993,20005,20013,20017,20043]
[20067,20071,20077,20085,20089,20101,20103,20121,20133,20149]
[20151,20169,20181,20185,20197,20203,20215,20227,20253,20257]
[20271,20295,20307,20319,20341,20349,20353,20355,20359,20371]
[20379,20385,20397,20403,20425,20445,20449,20455,20461,20475]
[20485,20487,20509,20511,20539,20551,20563,20581,20583,20587]
[20605,20611,20613,20649,20665,20679,20697,20713,20731,20733]
[20739,20757,20763,20769,20773,20793,20797,20805,20811,20821]
[20823,20833,20835,20839,20845,20859,20875,20887,20889,20899]
[20905,20923,20937,20941,20953,20959,20965,20991,21013,21015]
[21021,21027,21043,21049,21051,21055,21073,21075,21111,21115]
[21129,21139,21147,21153,21169,21175,21177,21189,21193,21199]
[21205,21211,21223,21231,21253,21255,21307,21309,21315,21327]
[21331,21337,21345,21373,21381,21405,21409,21411,21421,21433]
[21445,21451,21453,21469,21471,21475,21499,21505,21529,21531]
[21537,21549,21567,21571,21591,21597,21609,21613,21615,21621]
[21655,21663,21687,21693,21703,21709,21717,21721,21735,21739]
[21751,21757,21759,21771,21787,21819,21841,21847,21867,21885]
[21891,21897,21913,21915,21925,21927,21931,21933,21957,21967]
[21987,21993,22009,22017,22035,22039,22075,22087,22093,22095]
[22099,22113,22119,22125,22147,22155,22165,22167,22177,22185]
[22197,22225,22227,22231,22269,22281,22305,22327,22333,22339]
[22369,22371,22377,22381,22399,22401,22411,22417,22431,22437]
[22461,22471,22473,22479,22503,22507,22521,22525,22527,22533]
[22555,22569,22585,22587,22591,22597,22603,22617,22627,22629]
[22651,22683,22687,22689,22701,22711,22743,22779,22789,22791]
[22795,22807,22827,22839,22843,22851,22855,22869,22879,22881]
[22885,22893,22911,22921,22941,22947,22953,22957,22965,22969]
[22975,22981,22987,22999,23007,23031,23037,23041,23061,23067]
[23083,23089,23095,23101,23109,23137,23145,23163,23169,23173]
[23191,23193,23199,23205,23269,23271,23293,23295,23311,23323]
[23341,23343,23353,23355,23361,23365,23373,23377,23397,23419]
[23421,23427,23445,23449,23451,23457,23469,23479,23499,23515]
[23523,23529,23533,23551,23563,23565,23569,23571,23577,23607]
[23613,23649,23671,23677,23689,23701,23709,23721,23767,23775]
[23781,23799,23805,23815,23829,23835,23851,23857,23881,23889]
[23893,23913,23919,23925,23929,23943,23953,23955,23961,23965]
[23971,23973,23991,24013,24015,24025,24033,24037,24069,24073]
[24117,24121,24129,24133,24145,24151,24181,24183,24213,24217]
[24237,24247,24255,24261,24277,24285,24289,24301,24309,24321]
[24327,24331,24333,24343,24363,24381,24387,24397,24403,24405]
[24423,24429,24447,24451,24481,24499,24523,24531,24571,24573]
[24585,24591,24603,24619,24633,24637,24639,24643,24645,24649]
[24663,24669,24709,24711,24727,24729,24733,24739,24741,24759]
[24763,24771,24783,24789,24805,24811,24829,24831,24843,24855]
[24865,24873,24877,24895,24907,24909,24933,24951,24957,24963]
[24985,24991,25015,25017,25021,25033,25057,25063,25095,25099]
[25107,25117,25119,25129,25147,25153,25159,25167,25171,25185]
[25189,25201,25213,25215,25225,25237,25255,25263,25285,25287]
[25293,25309,25317,25335,25341,25347,25377,25389,25413,25425]
[25431,25441,25455,25461,25477,25483,25489,25497,25503,25525]
[25549,25561,25567,25569,25581,25591,25593,25611,25621,25623]
[25645,25647,25657,25671,25677,25687,25737,25753,25759,25771]
[25773,25803,25815,25819,25821,25833,25837,25845,25855,25861]
[25875,25893,25909,25917,25923,25929,25939,25959,25963,25971]
[25977,25987,26005,26007,26011,26025,26035,26041,26071,26085]
[26103,26107,26115,26119,26149,26155,26167,26169,26179,26209]
[26215,26217,26221,26229,26251,26263,26281,26293,26295,26301]
[26313,26319,26343,26347,26359,26365,26385,26397,26409,26413]
[26431,26445,26467,26505,26523,26529,26533,26547,26553,26565]
[26595,26599,26617,26629,26641,26649,26655,26659,26665,26683]
[26695,26697,26703,26719,26721,26727,26733,26749,26755,26757]
[26781,26797,26805,26841,26845,26847,26881,26883,26893,26905]
[26907,26913,26923,26925,26935,26943,26997,27001,27007,27009]
[27013,27027,27031,27033,27037,27039,27061,27063,27075,27079]
[27091,27093,27097,27105,27141,27157,27189,27195,27199,27201]
[27205,27207,27217,27237,27265,27271,27283,27301,27309,27315]
[27321,27325,27331,27333,27349,27357,27363,27387,27393,27409]
[27415,27417,27427,27435,27453,27457,27469,27475,27477,27483]
[27489,27493,27501,27511,27531,27541,27561,27585,27595,27597]
[27603,27639,27663,27667,27691,27693,27705,27711,27741,27751]
[27757,27765,27783,27793,27805,27807,27813,27829,27831,27847]
[27855,27859,27871,27879,27913,27915,27951,27961,27963,27975]
[28021,28023,28027,28039,28069,28071,28083,28087,28089,28101]
[28105,28119,28123,28129,28131,28141,28161,28167,28191,28195]
[28203,28233,28239,28245,28293,28311,28321,28329,28339,28351]
[28359,28365,28375,28393,28405,28417,28429,28435,28437,28459]
[28467,28483,28509,28513,28525,28563,28569,28581,28593,28605]
[28633,28639,28677,28689,28701,28707,28735,28759,28765,28771]
[28791,28797,28801,28803,28815,28825,28827,28837,28843,28855]
[28857,28867,28869,28887,28891,28905,28921,28923,28933,28951]
[28963,28969,28987,28989,28993,28995,29005,29025,29031,29035]
[29049,29055,29065,29089,29091,29095,29113,29121,29127,29137]
[29143,29149,29157,29175,29185,29193,29203,29205,29239,29253]
[29281,29283,29287,29295,29311,29317,29319,29329,29341,29349]
[29371,29391,29413,29437,29451,29457,29467,29473,29485,29487]
[29493,29497,29515,29517,29521,29533,29535,29563,29577,29589]
[29595,29599,29611,29613,29623,29625,29653,29659,29661,29665]
[29677,29689,29697,29709,29715,29721,29751,29757,29779,29781]
[29787,29791,29805,29815,29829,29845,29847,29851,29865,29877]
[29893,29905,29913,29925,29949,29959,29971,29973,29989,29995]
[30013,30021,30061,30067,30073,30075,30087,30103,30115,30121]
[30159,30163,30181,30207,30225,30229,30231,30241,30243,30253]
[30261,30265,30273,30289,30291,30303,30313,30327,30337,30367]
[30369,30373,30387,30397,30409,30411,30429,30439,30465,30471]
[30475,30477,30495,30499,30505,30523,30529,30537,30541,30543]
[30547,30559,30565,30567,30589,30601,30643,30651,30681,30687]
[30727,30747,30753,30765,30775,30777,30789,30793,30807,30817]
[30837,30849,30861,30871,30873,30877,30885,30901,30915,30919]
[30943,30945,30949,30969,30997,30999,31003,31021,31029,31033]
[31039,31051,31069,31071,31081,31093,31095,31107,31135,31137]
[31143,31147,31189,31191,31207,31221,31231,31237,31239,31249]
[31251,31255,31261,31263,31293,31303,31311,31315,31335,31341]
[31363,31381,31383,31387,31389,31395,31405,31411,31425,31429]
[31437,31449,31453,31489,31491,31515,31531,31545,31573,31611]
[31617,31633,31639,31641,31681,31699,31701,31713,31723,31737]
[31755,31765,31773,31789,31801,31807,31815,31839,31849,31863]
[31869,31879,31887,31893,31903,31927,31945,31953,31965,31971]
[31975,31977,31989,32005,32011,32013,32019,32041,32053,32055]
[32077,32079,32097,32101,32115,32119,32121,32133,32145,32173]
[32179,32197,32223,32229,32245,32247,32265,32269,32271,32277]
[32287,32311,32325,32329,32373,32385,32391,32397,32403,32407]
[32419,32433,32455,32457,32467,32481,32509,32533,32539,32545]
[32563,32571,32577,32593,32595,32605,32607,32613,32635,32637]
[32641,32643,32665,32683,32713,32727,32731,32745,32761,32769]
[32775,32793,32803,32827,32829,32833,32845,32853,32865,32869]
[32875,32889,32917,32919,32923,32937,32961,32973,32985,32997]
[33019,33021,33027,33033,33045,33067,33079,33091,33105,33109]
[33117,33121,33141,33151,33153,33169,33181,33183,33189,33205]
[33211,33217,33237,33247,33249,33273,33289,33297,33309,33313]
[33327,33333,33337,33349,33363,33375,33379,33381,33411,33423]
[33433,33435,33439,33445,33463,33465,33475,33495,33525,33537]
[33541,33549,33561,33567,33595,33601,33603,33615,33633,33645]
[33657,33673,33687,33705,33717,33721,33757,33769,33781,33805]
[33813,33835,33837,33843,33855,33861,33885,33895,33897,33907]
[33909,33925,33943,33949,33961,33973,33979,33987,33991,33993]
[34003,34005,34021,34027,34053,34065,34093,34099,34105,34107]
[34113,34125,34129,34131,34161,34171,34183,34191,34197,34201]
[34209,34213,34233,34257,34261,34281,34293,34305,34321,34323]
[34357,34359,34365,34377,34387,34399,34401,34423,34435,34449]
[34453,34461,34473,34485,34491,34497,34503,34507,34513,34557]
[34569,34573,34599,34603,34617,34621,34623,34639,34641,34653]
[34687,34713,34717,34719,34723,34725,34737,34755,34761,34767]
[34777,34785,34807,34809,34813,34821,34873,34875,34885,34887]
[34891,34909,34915,34917,34951,34957,34965,34971,34995,35011]
[35035,35041,35061,35071,35077,35091,35103,35113,35127,35137]
[35145,35155,35167,35169,35175,35197,35203,35205,35221,35223]
[35233,35287,35301,35317,35329,35331,35343,35349,35391,35395]
[35409,35413,35419,35421,35427,35443,35449,35451,35457,35461]
[35481,35485,35511,35539,35547,35557,35563,35577,35587,35601]
[35607,35611,35625,35643,35673,35683,35701,35703,35707,35709]
[35713,35721,35743,35799,35817,35833,35847,35859,35871,35881]
[35913,35917,35919,35941,35943,35959,35965,35973,36003,36025]
[36037,36039,36043,36051,36067,36085,36087,36099,36115,36129]
[36135,36147,36151,36165,36169,36175,36187,36205,36213,36231]
[36249,36255,36261,36273,36277,36297,36309,36319,36325,36331]
[36351,36361,36373,36375,36381,36405,36415,36417,36423,36427]
[36429,36451,36469,36481,36487,36499,36501,36513,36529,36541]
[36547,36549,36561,36573,36583,36603,36609,36613,36615,36619]
[36633,36669,36673,36675,36679,36681,36687,36691,36715,36721]
[36733,36741,36759,36763,36805,36823,36825,36829,36837,36855]
[36877,36891,36897,36903,36907,36943,36955,36963,36987,36993]
[36997,37011,37015,37023,37047,37051,37069,37075,37077,37081]
[37087,37089,37095,37117,37129,37161,37185,37195,37203,37215]
[37219,37239,37255,37263,37267,37279,37285,37287,37317,37339]
[37345,37365,37371,37383,37389,37393,37395,37435,37437,37447]
[37455,37467,37491,37495,37507,37509,37521,37527,37531,37533]
[37549,37569,37585,37597,37599,37621,37635,37663,37683,37689]
[37695,37705,37723,37729,37737,37747,37749,37753,37789,37801]
[37809,37813,37815,37833,37845,37851,37855,37893,37905,37909]
[37939,37941,37957,37959,37963,37969,37989,38001,38031,38035]
[38037,38041,38059,38067,38097,38119,38121,38131,38145,38149]
[38167,38185,38209,38221,38245,38247,38265,38271,38305,38307]
[38313,38319,38325,38341,38353,38355,38389,38391,38397,38401]
[38409,38421,38433,38439,38455,38461,38467,38473,38481,38503]
[38527,38535,38559,38563,38581,38599,38611,38623,38625,38629]
[38653,38661,38685,38695,38707,38713,38731,38737,38749,38751]
[38757,38769,38775,38779,38787,38791,38797,38799,38811,38815]
[38821,38839,38851,38853,38871,38875,38913,38917,38923,38925]
[38943,38949,38967,38985,38989,39007,39043,39045,39061,39067]
[39073,39093,39115,39123,39135,39139,39159,39171,39177,39193]
[39235,39249,39265,39271,39283,39285,39295,39301,39315,39321]
[39345,39355,39361,39367,39387,39411,39417,39441,39451,39463]
[39475,39481,39507,39513,39553,39567,39571,39573,39579,39585]
[39589,39607,39609,39615,39627,39633,39637,39643,39649,39673]
[39693,39705,39711,39721,39733,39741,39753,39769,39783,39795]
[39801,39825,39831,39837,39841,39849,39861,39865,39883,39889]
[39891,39903,39909,39931,39945,39955,39957,39967,39979,39987]
最後に、本稿を記載するために検証したHaskell環境を記しておきます。お手元の環境で検証する際に、動作が異なるときには参考になるかもしれません。
本稿の環境
本稿のために使用した環境は以下となります。
- macOS: Sonoma 14.5 (chip: Apple M1)
- GHCup: 0.1.30.0
- GHC: 9.6.4
ご一読いただきまして有り難うございます。
(●)(●) Happy Hacking!
/"" __""\