text: Sum of Area of all possible square inside a rectangle | C # program to calculate the sum of area of all possible squares that comes inside the rectangle ; Function to calculate the sum of area of all possible squares that comes inside the rectangle ; Square with max size possible ; calculate total square of a given size ; calculate area of squares of a particular size ; total area ; increment size ; Driver Code
code: using System ; class GFG { static int calculateAreaSum ( int l , int b ) { int size = 1 ; int maxSize = Math . Min ( l , b ) ; int totalArea = 0 ; for ( int i = 1 ; i <= maxSize ; i ++ ) { int totalSquares = ( l - size + 1 ) * ( b - size + 1 ) ; int area = totalSquares * size * size ; totalArea += area ; size ++ ; } return totalArea ; } public static void Main ( ) { int l = 4 , b = 3 ; Console . Write ( calculateAreaSum ( l , b ) ) ; } }