Sum of product of x and y such that floor ( n / x ) = y | C ++ 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 . ; Driven Program
#include <bits/stdc++.h> NEW_LINE using namespace std ; int sumofproduct ( int n ) { int ans = 0 ; for ( int x = 1 ; x <= n ; x ++ ) { int y = n / x ; ans += ( y * x ) ; } return ans ; } int main ( ) { int n = 10 ; cout << sumofproduct ( n ) << endl ; return 0 ; }