Question: Write a function sum_reciprocals() which takes 1 input argument, a positive integer n, and returns 1 output value, the sum of the reciprocals of

Write a function "sum_reciprocals()" which takes 1 input argument, a positive integer

 

Write a function "sum_reciprocals()" which takes 1 input argument, a positive integer "n", and returns 1 output value, the sum of the reciprocals of all integers from 1 to n (inclusive). The result should be returned as a floating point number, and rounded to 5 decimal places (use Python's "round()") function). For example: Test Result print (sum_reciprocals (2)) 1.5 print (sum_reciprocals (5)) 2.28333

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Python program to create and test the function sumreciprocals that takes an integer n and retu... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!