Number of rectangles in N * M grid | JAVA Code to count number of rectangles in N * M grid ; Driver code
import java . util . * ; class GFG { public static long rectCount ( int n , int m ) { return ( m * n * ( n + 1 ) * ( m + 1 ) ) / 4 ; } public static void main ( String [ ] args ) { int n = 5 , m = 4 ; System . out . println ( rectCount ( n , m ) ) ; } }