Harmonic Progression Python

PROGRAM TO PRINT SUM OF HARMONIC SERIES


def sum(n):
  
    # Base condition
    if n < 2:
        return 1
  
    else:
        return 1 / n + (sum(n - 1))
          
print(sum(8))
print(sum(10))


OUTPUT
2.7178571428571425
2.9289682539682538

Comments

Popular posts from this blog

Solve the Sudoku Python

Solve the Sudoku Java

Find Duplicates Java