费米-狄拉克素数是形式p^{2^k}的素数幂,其中p是素数和k \geq 0,或者换句话说,是整数幂为2的素数。它们被列为整数序列A050376。虽然正规素因式分解一般不包含一组不同的素数(例如24=2 \times 2 \times 2 \times 3),但费米-狄拉克素数分解最多包含每一个费米-狄拉克素数( 24=2 \times 3 \times 4 )。
您的任务是编写一个以整数n
作为输入并输出n
'th Fermi素数或从标准序列IO规则中选择任何其他选项的程序。
以字节为单位的最短代码获胜,没什么好笑的事。
1, 2
2, 3
3, 4
4, 5
5, 7
6, 9
7, 11
8, 13
9, 16
10, 17
100, 461
1000, 7649
6605, 65536
10000, 103919
100000, 1296749
1000000, 15476291
发布于 2022-10-24 09:20:45
.ℕ₂ḋ=l~^h2∧
;I{.ḋ=l~^h2∧}ᶠ⁽b
生成器是1索引的.整个程序输出第一个n
素数幂,0索引。
其实没那么慢。
.ℕ₂ Output is an integer in [2,+inf)
ḋ Its prime decomposition…
= …is a list of equal elements…
l …with a length…
~^h2∧ …being a power of 2
;I{ }ᶠ⁽ Find the first <Input> results of the following predicate:
.ḋ The prime decomposition of the Output…
= …is a list of equal elements…
l …with a length…
~^h2∧ … being a power of 2
b Remove the first result (1, whose prime decomposition is the empty list)
发布于 2022-10-25 01:58:09
发布于 2022-10-24 08:39:20
>Åp¤Ýoδm˜êNè
0-索引。
蛮力法,所以输入越大,速度越慢.
在网上试试或验证前10个测试用例 (用I>
代替¤
以加快速度,尽管n\geq15仍然超时)。
> # Increase the (implicit) input by 1 (for edge-case n=0)
Åp # Pop and push a list of the first input+2 amount of prime numbers
¤ # Push its last/largest prime (without popping the list)
Ý # Pop and push a list in the range [0,max_prime]
o # Get 2 to the power each value in this list
δ # Apply double-vectorized on the two lists:
m # Exponentiation
˜ # Flatten the list of lists
ê # Sorted-uniquify it
Iè # Get the input'th value of this list
# (after which it is output implicitly as result)
https://codegolf.stackexchange.com/questions/253682
复制相似问题