Equation...

I'm working on a problem that needs me to write a program that will compute this:
1.0/n + 2.0/(n-1) + 3.0/(n-2) + .... + (n-1)/2 + n/1

n is a positive integer that the user will punch in.

I don't really understand what the equation is, or what the "...." in the middle is supposed to imply. I'm not so great with math logic, obviously...

Is that space supposed to be (n-2)/3? Is it that simple? lol
The "...." means "and follow the pattern". The pattern is that for each element, the numerator goes up by one and the denominator goes down by one.

Say if n = 5, then your program should output the result of:

1.0/5 + 2.0/4 + 3.0/3 + 4.0/2 + 5.0/1
Aha! That makes a lot more sense. Thank you so much!! :-)
Yeah, thats the right answer. seems like the first and last, second and second last, and third and third last should all be reciprocals of each other by the pattern.

Um i would say..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
int main();
{
int answer;
int number;
std::cout << "Write in your number that you want to compute 1.0/n + 2.0/(n-1) + 3.0/(n-2) + .... + (n-1)/2 + n/1";

std::cin >> number;
answer = 1.0/number + 2.0/(number-1) + 3.0/(number-2) + (number-2)/3 + (number-1)/2 + number/1

std::cout << " your answer is " << answer;
return 0;
}

Or something like that. Ok im super new too so dont flame at me if im far from it

Thanks! That helps a lot, actually. I'm very new as well, so don't worry-- no bashing here! :-) I'll give this a try and see what happens.
Topic archived. No new replies allowed.