실제로 , 12 11 바이트
그의 많은 제안에 대해 Leaky Nun에게 감사드립니다. 골프 제안을 환영합니다. 온라인으로 사용해보십시오!
;)R♀ⁿ♀%0@íu
원래 12 바이트 접근 방식. 온라인으로 사용해보십시오!
1WX│1╖╜ⁿ%WX╜
또 다른 12 바이트 접근법. 온라인으로 사용해보십시오!
w┬i)♀/♂K@♀ⁿπ
13 바이트 접근법. 온라인으로 사용해보십시오!
k╗2`╜iaⁿ%Y`╓N
풀기 :
첫 번째 알고리즘
Implicitly pushes y, then x.
; Duplicate x.
) Rotate duplicate x to bottom of the stack.
R Range [1, x] (inclusive).
♀ⁿ Map a**y over the range.
♀% Map a**y%x over the range.
0@í new_list.index(0)
u Increment and print implicitly at the end of the program.
원래 알고리즘
Implicitly pushes x, then y.
1WX Pushes a truthy value to be immediately discarded
(in future loops, we discard a**y%x)
| Duplicates entire stack.
Stack: [y x y x]
1╖ Increment register 0.
╜ Push register 0. Call it a.
ⁿ Take a to the y-th power.
% Take a**y mod x.
W If a**y%x == 0, end loop.
X Discard the modulus.
╜ Push register 0 as output.
세 번째 알고리즘
Implicitly pushes y, then x.
w Pushes the full prime factorization of x.
┬ Transposes the factorization (separating primes from exponents)
i Flatten (into two separate lists of primes and exponents).
) Rotate primes to the bottom of the stack.
♀/ Map divide over the exponents.
♂K Map ceil() over all of the divided exponents.
@ Swap primes and modified exponents.
♀ⁿ Map each prime ** each exponent.
π Product of that list. Print implicitly at the end of the program.
네 번째 알고리즘
Implicitly pushes x, then y.
k╗ Turns stack [x y] into a list [x, y] and saves to register 0.
2 Pushes 2.
` Starts function with a.
╜i Pushes register 0 and flattens. Stack: [x y a]
a Inverts the stack. Stack: [a y x]
ⁿ% Gets a**y%x.
Y Logical negate (if a**y is divisible by x, then 1, else 0)
` End function.
╓ Push first (2) values where f(x) is truthy, starting with f(0).
N As f(0) is always truthy, get the second value.
Print implicitly at the end of the program.