Sum of series ( n / 1 ) + ( n / 2 ) + ( n / 3 ) + ( n / 4 ) + ... ... . + ( n / n ) | function to find sum of series ; Driver code
function sum ( n ) { let root = parseInt ( Math . sqrt ( n ) ) ; let ans = 0 ; for ( let i = 1 ; i <= root ; i ++ ) ans += parseInt ( n / i ) ; ans = ( 2 * ans ) - ( root * root ) ; return ans ; } let n = 35 ; document . write ( sum ( n ) ) ;