Sum of product of x and y such that floor ( n / x ) = y | Java program to find sum of product of x and y such that n / x = y ( Integer Division ) ; 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
import java . io . * ; class GFG { static int sumofproduct ( int n ) { int ans = 0 ; for ( int x = 1 ; x <= n ; x ++ ) { int y = n / x ; ans += ( y * x ) ; } return ans ; } static public void main ( String [ ] args ) { int n = 10 ; System . out . println ( sumofproduct ( n ) ) ; } }