Problem 3003. Mobius function

From wikipedia:
For any positive integer n, define μ(n) as the sum of the primitive n-th roots of unity. It has values in {−1, 0, 1} depending on the factorization of n into prime factors:
  • μ(n) = 1 if n is a square-free positive integer with an even number of prime factors.
  • μ(n) = −1 if n is a square-free positive integer with an odd number of prime factors.
  • μ(n) = 0 if n has a squared prime factor.
Return numbers from the Mobius function sequence corresponding to the supplied indices. For example, if n = 3:7, your function should return [-1, 0, -1, 1, -1].
Hint: solving Problem 3001 and Problem 3002 will provide much of the code needed for this problem. You'll need to add prime numbers to the sphenic number set (resulting from Problem 3001).

Solution Stats

57.94% Correct | 42.06% Incorrect
Last Solution submitted on Jan 20, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers50

Suggested Problems

More from this Author139

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!