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