programming-examples/python/Function/Python program to calculate the harmonic sum of n-1.py
2019-11-15 12:59:38 +01:00

8 lines
168 B
Python

def harmonic_sum(n):
if n < 2:
return 1
else:
return 1 / n + (harmonic_sum(n - 1))
print(harmonic_sum(7))
print(harmonic_sum(4))