Number of cells in the Nth order figure | Function to return the number of cells in the nth order figure of the given type ; Driver code
function cntCells ( n ) { var cells = Math . pow ( n , 2 ) + Math . pow ( n - 1 , 2 ) ; return cells ; } var n = 3 ; document . write ( cntCells ( n ) ) ;