私は知っています、私は知っています、さらに別の素数の挑戦...
孤独(または単離された)プライムは素数であるp
ようにp-2
、p+2
、p-4
、p+4
... p-2k
、p+2k
いくつかのためにk
すべての複合です。このような素数をth回分離素数と呼びますk
。
たとえば211
、すべて201, 203, 205, 207, 209, 213, 215, 217, 219, 221
が複合であるため、5回分離された素数はです。(p-2*5=201
、p-2*4=203
など)
チャレンジ
2つの入力整数、n > 3
およびが与えられた場合、厳密により大きいk > 0
最小のk
th回分離された素数を出力しn
ます。
たとえば、範囲内のk = 5
anyの場合、出力はである必要があります。これは、入力より厳密に大きい最小の5回分離された素数であるためです。n
4 ... 210
211
n
例
n=55 k=1
67
n=500 k=1
503
n=2100 k=3
2153
n=2153 k=3
2161
n=14000 k=7
14107
n=14000 k=8
14107
ルール
k
定義により、th-times-isolatedはk-1
th、k-2
thなどです