Friday, February 1, 2019

Solve Equation

  • Problem Description

    Python Program to Find the Sum of the Series: 1 + 1/2 + 1/3 + .. + 1/N

    Input:

    The number of terms

    Output

    Print the Sum of Series
  • CODING ARENA
  • n=int(input())
    sum1=0
    for i in range(1,n+1):
        sum1=sum1+(1/i)
    print(round(sum1,2))
  • Test Case 1

    Input (stdin)
    7
    
    
    Expected Output
    2.59
  • Test Case 2

    Input (stdin)
    15
    
    
    Expected Output
    3.32

No comments:

Post a Comment