Apothem of a n | Function to find the apothem of a regular polygon ; Side and side length cannot be negative ; Degree converted to radians ; Driver code
< ? php function polyapothem ( $ n , $ a ) { if ( $ a < 0 && $ n < 0 ) return -1 ; return $ a / ( 2 * tan ( ( 180 / $ n ) * 3.14159 / 180 ) ) ; } $ a = 9 ; $ n = 6 ; echo polyapothem ( $ n , $ a ) . " STRNEWLINE " ; ? >