Harmonic numbers (1) P59539


Statement
 

pdf   zip

thehtml

Write a program that reads a number n and prints the n-th harmonic number, defined as Hn = 1/1 + 1/2 + ⋯ + 1/n.

Input

Input consists of a natural number n.

Output

Print Hn with 4 digits after the decimal point.

Public test cases
  • Input

    2
    

    Output

    1.5000
    
  • Input

    0
    

    Output

    0.0000
    
  • Input

    7
    

    Output

    2.5929
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Salvador Roura
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Java Python
    User solutions
    C C++ Java PHP Python Rust