logo CodeStepByStep logo

SumUpTo

Language/Type: C# recursion

Write a recursive method named SumUpTo that accepts an integer parameter n, where SumUpTo(n) returns: 1 + 1/2 + 1/3 + 1/4 + ... + 1/n .

For example, the call of SumUpTo(2) should return 1.5. You should return 0.0 if n is 0, and you should throw an ArgumentException if n is less than 0.

Method: Write a C# method as described, not a complete program or class.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.