Sum of series ( n / 1 ) + ( n / 2 ) + ( n / 3 ) + ( n / 4 ) + ... ... . + ( n / n ) | C # program to find sum of given series ; Function to find sum of series ; Driver code
using System ; class GFG { static long sum ( long n ) { long root = ( long ) Math . Sqrt ( n ) ; long ans = 0 ; for ( int i = 1 ; i <= root ; i ++ ) ans += n / i ; ans = 2 * ans - ( root * root ) ; return ans ; } public static void Main ( ) { long n = 35 ; Console . Write ( sum ( n ) ) ; } }