Comments

See the example for the Euler's totient function in the linear sieve tutorial.

For the Möbius function the three cases are:
1) if x is prime: mobius[x]=-1 (obiously the number of prime factors of a prime number is odd)
2) x=ip and i%p!=0: mobius[x]=mobius[i]*mobius[j] (since the function is multiplicative)
3) x=ip and i%p==0: mobius[x]=0 (p^2 divides x)