I'm trying to develop a Python 3 program that will allow the user to choose a denominator and evaluate an equation. For Example:
- The user selects 5 to be the denominator
- The equation will increment until the given denominator
- (1/1) + (1/2) + (1/3) + (1/4) + (1/5)
- The output should be (2.283333)
My code:
d = input ("Select a denominator")
for i in range(d)
d += (1/d)
print(d)
So far I'm only able to ask the user for the input/denominator. I tried putting it in a loop but I am doing something wrong. This is what prints out:
5.2
5.392307
5.577757
5.757040
5.930740