Area of decagon inscribed within the circle | Function to find the area of the decagon ; radius cannot be negative ; area of the decagon ; Driver code
function area ( r ) { if ( r < 0 ) return - 1 ; var area = ( 5 * Math . pow ( r , 2 ) * ( 3 - Math . sqrt ( 5 ) ) * ( Math . sqrt ( 5 ) + ( ( 2 * Math . sqrt ( 5 ) ) ) ) / 4 ) ; return area ; } var r = 8 ; document . write ( area ( r ) . toFixed ( 3 ) ) ;