如果n是Rocco数,则返回1,否则返回0。n0
fDŠ/α14å
在线尝试!
怎么样?
给定一个正整数n,我们测试是否存在素数p为n,使得:
∣∣∣p−np∣∣∣=14
已评论
fDŠ/α14å # expects a positive integer n as input e.g. 2655
f # push the list of unique prime factors of n --> 2655, [ 3, 5, 59 ]
D # duplicate it --> 2655, [ 3, 5, 59 ], [ 3, 5, 59 ]
Š # moves the input n between the two lists --> [ 3, 5, 59 ], 2655, [ 3, 5, 59 ]
/ # divide n by each prime factor --> [ 3, 5, 59 ], [ 885, 531, 45 ]
α # compute the absolute differences
# between both remaining lists --> [ 882, 526, 14 ]
14å # does 14 appear in there? --> 1