Update primes.cpp

This commit is contained in:
Anthony Wang 2020-09-19 11:18:23 -05:00
parent 64ad955a27
commit c4c2232868
No known key found for this signature in database
GPG key ID: DCDAC3EF330BB9AC

View file

@ -33,7 +33,7 @@ vector<ii> factorize(ll N) {
ll num_pf(ll N) {
ll idx = 0, pf = pr[idx], ans = 0;
while (N != 1 && pf * pf <= N)) {
while (N != 1 && pf * pf <= N) {
while (N % pf == 0) { N /= pf; ans++; }
pf = pr[++idx];
}
@ -52,7 +52,7 @@ ll num_diff_pf(ll N) {
ll sum_pf(ll N) {
ll idx = 0, pf = pr[idx], ans = 0;
while (N != 1 && pf * pf <= N)) {
while (N != 1 && pf * pf <= N) {
while (N % pf == 0) { N /= pf; ans += pf; }
pf = pr[++idx];
}
@ -61,7 +61,7 @@ ll sum_pf(ll N) {
ll num_div(ll N) {
ll idx = 0, pf = pr[idx], ans = 1;
while (N != 1 && pf * pf <= N)) {
while (N != 1 && pf * pf <= N) {
ll power = 0;
while (N % pf == 0) { N /= pf; ++power; }
ans *= (power + 1);
@ -90,4 +90,4 @@ ll phi(ll N) {
pf = pr[++idx];
}
return N != 1 ? ans - ans / N : ans;
}
}