ll totient_function(ll n) { ll result = n; for (int i = 2; n/i >= i; ++i) if (n % i == 0) { while (n % i == 0) n /= i; result = result - result / i; } if (n > 1) result = result - result / n; return result; }
ll totient_function(ll n) { ll result = n; for (int i = 2; n/i >= i; ++i) if (n % i == 0) { while (n % i == 0) n /= i; result = result - result / i; } if (n > 1) result = result - result / n; return result; }