MCPcopy Index your code
hub / github.com/geekcomputers/Python / mobius_function

Function mobius_function

MobiusFunction.py:29–40  ·  view source on GitHub ↗

Defines Mobius function

(n)

Source from the content-addressed store, hash-verified

27
28
29def mobius_function(n):
30 """
31 Defines Mobius function
32 """
33 factors = prime_factors(n)
34 if is_square_free(factors):
35 if len(factors) % 2 == 0:
36 return 1
37 elif len(factors) % 2 != 0:
38 return -1
39 else:
40 return 0

Callers

nothing calls this directly

Calls 2

prime_factorsFunction · 0.85
is_square_freeFunction · 0.85

Tested by

no test coverage detected