Program for weighted mean of natural numbers . | Program to find weighted mean of first n natural numbers using formula . ; Returns weighted mean assuming for numbers { 1 , 2 , . . n } and weights { 1 , 2 , . . n } ; Driver program to test the function .
#include <bits/stdc++.h> NEW_LINE using namespace std ; int weightedMean ( int n ) { return ( 2 * n + 1 ) / 3 ; } int main ( ) { int n = 10 ; cout << weightedMean ( n ) ; return 0 ; }