Average of odd numbers till a given odd number | Function to calculate the average of odd numbers ; Driver Code
< ? php function averageOdd ( $ n ) { if ( $ n % 2 == 0 ) { echo ( " Invalid ▁ Input " ) ; return -1 ; } return ( $ n + 1 ) / 2 ; } $ n = 15 ; echo ( averageOdd ( $ n ) ) ; ? >