I wonder if there is any efficient way to calculate Möbius function for a array of number 1:1000000
Here are a few papers that might be helpful. Shallit and Shamir, Numbertheoretic functions which are equivalent to number of divisors, Inform. Process. Lett. 20 (1985), no. 3, 151–153, MR0801982 (86k:11076). The review, by Hale Trotter, says $\mu(n)$ can be calculated from a single value $d(n^q)$ where $d$ is the divisor function and $q$ is a prime greater than $1+\log_2n$. Lioen and van de Lune, Systematic computations on Mertens' conjecture and Dirichlet's divisor problem by vectorized sieving, in From Universal Morphisms to Megabytes: a Baayen Space Odyssey, 421–432, Math. Centrum, Centrum Wisk. Inform., Amsterdam, 1994, MR1490603 (98j:11125). The review, by Jonathan P. Sorenson, says the authors present sieving algorithms for computing $\mu(n)$. Herman te Riele, Computational sieving applied to some classical numbertheoretic problems, in Number Theory in Progress, Vol. 2 (ZakopaneKościelisko, 1997), 1071–1080, de Gruyter, Berlin, 1999, MR1689561 (2000e:11119). The review, by Marc Deléglise, starts, "This paper is a survey about different applications of sieving in number theory. Finding all the primes belonging to a given interval and computing all the values of the Möbius function on a given interval are obvious examples." 


I also like thisone, $\mathcal{O}(N \ln N)$ additions being not so different of $\mathcal{O}(N \ln \ln N)$ multiplications :
I'll leave you as an exercice to prove that it effectly computes $\mu(n)$ $$ \left(\sum_n \mu_n n^0 \right) \left(\sum_m m^0 \right) = \sum_n n^0 \sum_{d  n} \mu_d$$ 


The key phrase here is for an array. Then try the Sieve of Eratosthenes:
We stop at power $2$ since we are just looking for squarefree (OEIS: A005117). This is certainly not the fastest but maybe easiest to implement. I downloaded a list of primes off the internet (or you can generate or find your own sieve).
The output looks good (See also OEIS:A008683)
The Sieve
This is a sample implementation. The results, they look correct:



You don't need the bigger machinery of a segmented sieve for such a small range. Here is a simple $O(n\log\log n)$ algorithm to calculate all $\mu(i)$ up to $n$ based on the Sieve of Eratosthenes. In fact, the sieve does fully factor all the squarefree numbers; it just doesn't do it one at a time. Depending on your computer, this approach is practical up to around $2^{30}$ at which point you need to start using higherprecision arithmetic and computing a range of $\mu(i)$ values in batches.
Running 


For range 1:1000000 the stupidest possible algorithm (factor each integer, check if it's square free, raise 1 to the right power) will terminate in a blink of an eye. For much larger ranges, an obvious modifican of the sieve of erathsosphenes will be very fast ( just remember to zero every $p$th number at the $p$th step. 

