Find the number of squares inside the given square grid | Function to return the number of squares inside an n * n grid ; Driver code
function cntSquares ( n ) { return n * ( n + 1 ) * ( 2 * n + 1 ) / 6 ; } document . write ( cntSquares ( 4 ) ) ;