Maximum number of 2 x2 squares that can be fit inside a right isosceles triangle | Java program to count number of 2 x 2 squares in a right isosceles triangle ; removing the extra part we would always need ; Since each square has base of length of 2 ; Driver code
class Squares { public static int numberOfSquares ( int base ) { base = ( base - 2 ) ; base = Math . floorDiv ( base , 2 ) ; return base * ( base + 1 ) / 2 ; } public static void main ( String args [ ] ) { int base = 8 ; System . out . println ( numberOfSquares ( base ) ) ; } }