Program for weighted mean of natural numbers . | Returns weighted mean assuming for numbers { 1 , 2 , . . n } and weights { 1 , 2 , . . n } ; Driver Code
< ? php function weightedMean ( $ n ) { return ( 2 * $ n + 1 ) / 3 ; } $ n = 10 ; echo ( weightedMean ( $ n ) ) ; ? >