## C++ quick question

• How would you make a loop to solve the following summation: sqrt (3) / (1 x 2) + sqrt (4) / (2 x 3) + sqrt (5) / (3 x 4) + ... + sqrt (99) / (97 x 98) + sqrt (100) / (98 x 99).

Here is what I can get:

double sum, x, y, z;
x = 3;
y = 1;
z = 2;
sum = 0;

while (x
{
sum = sqrt (x) / (y * z);
x++;
y++;
z++;
}

cout

I am stumped on how to complete this loop to get the right answer. =(

Any help would be greatly appreciated!
• I don't see a problem on your algorithm, but... just this:

sum = sqrt (x) / (y * z);

shouldn't be this?:

sum += sqrt (x) / (y * z);
• double sum = 0;
int x;

for(x=3; x
sum+= sqrt(x)/((x-2)(x-1));
}
• Quote from Flashk

I don't see a problem on your algorithm, but... just this:

sum = sqrt (x) / (y * z);

shouldn't be this?:

sum += sqrt (x) / (y * z);

Thank you so much!!!! Lol, I couldn't figure out what was going wrong haha! =)
• You are welcome!
• Or as a Python list comprehension:

sum(math.sqrt(x) / ((x-2)*(x-1)) for x in range(3,101)) = 2.244

Sorry, couldn't resist