0

I want to calculate the sum of first $n$ natural numbers. I used the following C program to compute the first '$n$' digits :

#include <stdio.h>
int main() {
    int n;
    double m;
    double sum=0;
    scanf("%d", &n);
    while (n>0) {
        m=1.0/n;
        sum+=m;
        n--;
    }
    printf("%lf",sum);
    return(0);
}

What I get is that the sum is very slowly diverging.

  1. For $10^{1}$, I get the value : $2.92...$
  2. For $10^{14}$, I get the value : $18.807..$
  3. For $10^{16}$, I get the value : $21.92..$

So it appears to diverge.

How can we prove it? Actually sum of reciprocals is divergent, even after being a subseries of this series, so it naturally should be divergent. How can we show this?

0 Answers0