feat: upate phi

This commit is contained in:
2025-07-18 00:01:35 +08:00
parent 5ac2a0a8ad
commit f3b35ccc43

View File

@@ -17,7 +17,9 @@ public class Phi {
public static BigInteger phi(BigInteger n) {
BigInteger p = BigInteger.valueOf(0);
BigInteger i = BigInteger.valueOf(1);
// for i \in [1, n)
while (i.compareTo(n) < 0) {
// gcd(i, n) = 1
if (i.gcd(n).equals(BigInteger.ONE)) {
p = p.add(BigInteger.ONE);
}