別のシーケンス、別の課題。*
定義
首相はp
このシーケンスである、レッツ・コールもA
、すべての桁のIFF d
でp
の小数点以下の拡張、あなたが代わるd
とd
のコピーd
と結果の整数はまだ素数です。ゼロは許可されません。
たとえば11
、このシーケンスでは些細なことです(ちなみに、最初の数字です)。シーケンスの次はある31
ので、3331
また、素数です。その後53
ためには55555333
そうでも素数である、と。
チャレンジ
input n
、return A(n)
、つまりn
このシーケンスのth番目のアイテムを指定します。
例
始めるための最初の20の用語を以下に示します。これは、OEIS上のA057628です。
11, 31, 53, 131, 149, 223, 283, 311, 313, 331, 397, 463, 641, 691, 937, 941, 1439, 1511, 1741, 1871
これはA(0) = 11
、A(1) = 31
ゼロインデックスを使用する場合、などを意味します。
ルール
- ゼロベースまたは1ベースのインデックスを選択できます。あなたの答えにどれを指定してください。
n
th要素だけを返す代わりに、最初のn
用語を返すことを選択できます。- 入力/出力は、あなたの言語のネイティブ整数フォーマットよりも大きくないと仮定できます。ただし、繰り返し数字の素数は言語のネイティブ形式よりも大きい場合があるため、これを考慮する必要があります。
- たとえば
1871
、最後の例のには、対応する素数があり18888888877777771
、標準のINT32よりもかなり大きくなっています。 - 完全なプログラムまたは機能のいずれかが受け入れられます。関数の場合、出力する代わりに出力を返すことができます。
- 出力は、コンソールに出力したり、関数から返されたり、警告ポップアップに表示したりできます。
- 標準的な抜け穴は禁止されています。
- これはコードゴルフなので、通常のゴルフルールがすべて適用され、最短のコード(バイト単位)が勝ちます。
*公平を期すために、私はシーケンスの最初のいくつかの用語をいくつかの数字で遊んでいたので、OEISに行って残りのシーケンスを取得しました。
169
自体は素数ではないため、13 * 13
です。