Answers:
(毫无疑问,这里可以打高尔夫球!-是的...)-4
个字节,感谢@Dennis-通过使用范围替换大于n的检查
ÆRẆP€ḟÆRfR
注意-这既效率极低,而且结果未排序。
怎么样?
ÆRẆP€ḟÆRfR - main link takes an argument, n
ÆR ÆR - primes up to n
Ẇ - all sublists
P€ - product for each
ḟ - filter out the primes (since the sublists include those of lnegth 1)
fR - filter out any not in range [1,N]
(yep, it's calculating all products of primes up to n - gross)
µ
和³
; >Ðḟ
本身就可以正常工作。fR
更短。
Zq&Xf"@gnq?2MpG>~?6M
方法类似于乔纳森·艾伦(Jonathan Allan)的回答。
:YF!"@2<@sq0@0hhdz2=v?X@D
这将获得从1
到输入的所有数字的素因分解指数。对于每个它检查:
如果满足这三个条件,则会显示数字。结果按升序排列。
f}PTftlY.:fP_YSQ)S
一个程序,该程序在STDIN上输入整数并输出整数列表。
这个怎么运作
f}PTftlY.:fP_YSQ)S Program. Input: Q
SQ Yield [1, 2, 3, ..., Q]
fP_Y Filter that by primality
.: ) Yield all sublists of that
f Filter the sublists by:
lY Length
t -1
removing sublists of length 1
f S Filter [1, 2, 3, ..., Q] (implicit input fill) by:
PT Prime factorisation
} is in the sublists
Implicitly print
ÆfÆCI=1Ȧµ€T
这不是最简单的Jelly答案,但是这种方法非常有效,并且可以对输出进行排序。
ÆfÆCI=1Ȧµ€T Main link. Argument: n
µ€ Map the preceding chain over each k in [1, ..., n].
Æf Compute all prime factors of k, with multiplicities.
ÆC Count the number of primes less than or equal to each prime factor.
This maps the j-th to j.
I Increments; compute the forward differences of consecutive indices.
=1 Compare each difference with 1.
Ȧ All; return 1 iff the array is non-empty and has no zeroes.
T Truth; yield all indices for which the chain returned 1.