for this :
S = 1/(1*2) + 1/(2*3) + 1/(3*4) + ... + 1/(n * n+1)
is this correct :
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
int a=1, b=2, sum, n;
cin >> n;
for(int i=0; i<n; i++){
sum += 1/(a*b);
a++;
b++;
}
cout << sum;
}
first you used integer division with truncate to integers
second this is https://math.stackexchange.com/questions/1027110/infinite-series-sum-1-nn1
inverse of https://en.wikipedia.org/wiki/Pronic_number
Stefan
mahdi13
Al
imran
!/usr
olli
Iakovos