sum of divisors for given range of numbers from 1 to n

2.9k Views Asked by At

we are given a function F(n) for a number n which is defined as sum of the divisors of n (including 1 and n) ... now given an integer N we have to calculate
G(n) = F(1) + F(2) + F(3) + ..... + F(n)... is there any formula for it??? i saw "Peter Gustav Lejeune Dirichlet " formula that can be used while surfing the net...can this be used??if yes, please provide an explanation for this formula??if no, then provide another method that can be used

1

There are 1 best solutions below

4
On BEST ANSWER

If $f\left(k,n\right)$ denotes the cardinality of $\left\{ i\in\left\{ 1,\ldots,n\right\} \mid k\text{ divides }i\right\} $ then $G\left(n\right)=\sum_{k=1}^{n}kf\left(k,n\right)$. Here $f\left(k,n\right)=\lfloor\frac{n}{k}\rfloor$ so $G\left(n\right)=\sum_{k=1}^{n}k\times\lfloor\frac{n}{k}\rfloor$.

Take a number, $3$ for instance, and wonder in what $F\left(i\right)$ it will turn up as a term. This is the case if $3$ is a divisor of $i$. Here $f\left(3,n\right)=\lfloor\frac{n}{3}\rfloor$ expresses the number of times that $3$ turns up as a term of $G\left(n\right)$

Edit:

Let say that $X_{k,i}=1$ if $k|i$ and $X_{k,i}=0$ otherwise.

Then for $i\leq n$ we have $F\left(i\right)=\sum_{k=1}^{n}k\times X_{k,i}$. So $G\left(n\right)=\sum_{i=1}^{n}F\left(i\right)=\sum_{i=1}^{n}\sum_{k=1}^{n}k\times X_{k,i}=\sum_{k=1}^{n}\sum_{i=1}^{n}k\times X_{k,i}=\sum_{k=1}^{n}k\sum_{i=1}^{n}X_{k,i}=\sum_{k=1}^{n}k\lfloor\frac{n}{k}\rfloor$