library

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

View the Project on GitHub firiexp/library

:warning: math/mobius_mu.cpp

Code

int mobius_mu(ll n) {
	int res = 0;
	for(ll d = 2; d*d <= n; d++) {
		if(n % (d*d) == 0) return 0;
		else if(n % d == 0) n /= d, res++;
	}
	if(n != 1) res++;
	return res&1 ? -1 : 1;
}
#line 1 "math/mobius_mu.cpp"
int mobius_mu(ll n) {
	int res = 0;
	for(ll d = 2; d*d <= n; d++) {
		if(n % (d*d) == 0) return 0;
		else if(n % d == 0) n /= d, res++;
	}
	if(n != 1) res++;
	return res&1 ? -1 : 1;
}
Back to top page