logo CodeStepByStep logo

fraction_sum

Write a function named fraction_sum that accepts an integer parameter n and returns the sum of the first n terms of the sequence:

fraction sum equation

In other words, the function should generate the following sequence:

1 + (1/2) + (1/3) + (1/4) + (1/5) + ... + (1/n)

You may assume that the parameter n is non-negative.

Function: Write a Python function as described, not a complete program.

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.