Average of first n odd naturals numbers | Returns the Avg of first n odd numbers ; sum of first n odd number ; Average of first n odd numbers ; Driver Code
< ? php function avg_of_odd_num ( $ n ) { $ sum = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) $ sum += ( 2 * $ i + 1 ) ; return $ sum / $ n ; } $ n = 20 ; echo ( avg_of_odd_num ( $ n ) ) ; ? >