这不是一个大程序。每行是一个单独的替代程序,用于处理素数检查(不使用素数内置函数)。
ÑPQ
ÒgΘ
ÒQP
ÕαΘ
fQO
fs¢
f`Q
-2个字节感谢Grimy。
行之间的空格在05AB1E中是空操作,并且由于我仅使用1字节命令,因此在转置后可以正常工作。
输出1
/ 0
对truthy / falsey分别。
在线尝试第一个或验证所有其他的测试用例(内置eval .V
)。
转置:在线尝试第一个。
说明:
Ñ # Get a list of all divisors of the (implicit) input-integer
# (which would be only 1 and the integer itself for primes)
P # Take the product of that list
Q # And check if it's equal to the (implicit) input-integer
Ò # Get a list of all prime factors of the (implicit) input-integer
g # Get the amount of those prime factors by taking the length of the list
Θ # Check if that's equal to 1 (so only itself is a prime factor)
Ò # Get a list of all prime factors of the (implicit) input-integer including duplicates
Q # Check for each if it's equal to the (implicit) input-integer
# (1 if truthy; 0 if falsey)
P # Take the product of those checks (resulting in either 1 or 0 as well)
Õ # Get the Euler totient of the (implicit) input-integer
α # Take the absolute difference with the (implicit) input-integer
Θ # Check if that's equal to 1
f # Get a list of all prime factors of the (implicit) input-integer without duplicates
Q # Check for each if it's equal to the (implicit) input-integer
O # And take the sum of that (resulting in either 1 or 0)
f # Get a list of all prime factors of the (implicit) input-integer without duplicates
s # Swap to get the (implicit) input-integer
¢ # And count how many time it occurs in the list
f # Get a list of all prime factors of the (implicit) input-integer without duplicates
` # Dump all the content of this list onto the stack
Q # Check if the top two values are equal, or if only a single value is present, it will
# use the (implicit) input-integer as second value
# For all these program the same applies at the end:
# (implicitly output the result with trailing newline)
注:如果只有truthy / falsey值是有效的,而且它并不一定必须是不同的,无论是Òg
或Õα
可以作为有效的2-byters,因为只有1
是在truthy 05AB1E,一切是falsey:尝试两个他们为一些测试用例。
如果允许使用内置函数,那么只需一个p
就足够了:在线尝试或验证更多测试用例。