Divisor Function

542 Views Asked by At

Divisor Function d(N) is the number of divisors of N less than or equal to N. Ex. d(1)=1,d(2)=2,d(10)=4...so on....

I had a question that says to compute answer to function Z(N)=d(1)+d(2)+d(3)....d(N) After some thinking I figured out Z(N)= N+(N/2)+(N/3)....+1 .

But I got stuck here because if I take N common... Z(N)=N(1+(1/2)+(1/3).....(1/N)) and Z(N)~~N*ln(N+.52771).... But I want accurate answer.

Can somebody give a elegant answer since N can be very large...

2

There are 2 best solutions below

0
On

Terence Tao has an archive "What's new", and there is a nice article on the divisor function $$ d(n)=\sum_{d\mid n} 1 $$ and the sum $$ \sum_{n\le x}d(n)=\sum_{d\le x}\sum_{n\le x,\; d\mid n}1=\sum_{d\le x}\left(\frac{x}{d}+O(1)\right)=x\log x+O(x), $$ and better estimates - if you want an elegant answer. The archive can be found here: http://terrytao.wordpress.com/tag/divisor-function/.

0
On

If instead of looking at $N/2, N/3, N/4$, all the way to $N$, you could save yourself some time by considering that $a<b$ in $ab$, you don't have to count $b$ separately.

For example, suppose you want to look at the sum of divisors to $120$. So, if we look for instances of $a \ne b$ in $ab$, we count only the lesser divisor, and we count the squares just once.

For example, removing the first 9 multiples of 9, where 9 is the larger divisor, gives just $120/9-9=4$, which are $90, 99, 108, 117$ The larger divisors here are $10, 11, 12, 13$. For $10$, we have $120/10-10 = 2$, we count $110, 120$.

So, we get $120/1-1 = 119$, and $120/2-2 = 58$ and $120/3-3= 37$ and $120/4-4 = 26$, and $120/5-5 = 19$, and $120/6-6 = 14$, and $120/7-7 = 10$, and $120/8-8 = 7$, and $120/9-9=4$, and $120/10-10 = 2$, and $120/11-11 < 0$.

We add $119+58+37+26+19+14+10+7+4+2 = 296$ pairs of the form $ab, a<b$, and $10$ squares, so the total number of divisors is $296+296+10 = 602$.