Program to find sum of harmonic series | Function to return sum of harmonic series ; Driver code
function sum ( n ) { let i , s = 0.0 ; for ( i = 1 ; i <= n ; i ++ ) s = s + 1 / i ; return s ; } let n = 5 ; document . write ( " " + sum ( n ) ) ;