Count of squares that can be drawn without lifting the pencil | Function to return the count of squares that can be formed ; Driver code
function countSquares ( n ) { return ( Math . pow ( n , 2 ) - ( 2 * n ) + 2 ) ; } var n = 2 ; document . write ( countSquares ( n ) ) ;