library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub firiexp/library

:warning: math/eulerphi.cpp

Code

int eulerphi(int x){
    int phi = x, xx = x;
    for (int i = 2; i * i <= x; ++i) {
        if (xx % i == 0) {
            phi -= phi / i;
            while(xx % i == 0) xx /= i;
        }
    }
    if(xx > 1) phi -= phi/xx;
    return phi;
}
#line 1 "math/eulerphi.cpp"
int eulerphi(int x){
    int phi = x, xx = x;
    for (int i = 2; i * i <= x; ++i) {
        if (xx % i == 0) {
            phi -= phi / i;
            while(xx % i == 0) xx /= i;
        }
    }
    if(xx > 1) phi -= phi/xx;
    return phi;
}
Back to top page