Sum of product of x and y such that floor ( n / x ) = y | Return the sum of product x * y . ; Iterating x from 1 to n ; Finding y = n / x . ; Adding product of x and y to answer . ; Driver Code
< ? php function sumofproduct ( $ n ) { $ ans = 0 ; for ( $ x = 1 ; $ x <= $ n ; $ x ++ ) { $ y = ( int ) ( $ n / $ x ) ; $ ans += ( $ y * $ x ) ; } return $ ans ; } $ n = 10 ; echo sumofproduct ( $ n ) ; ? >