text: Maximum number of 2 x2 squares that can be fit inside a right isosceles triangle | C ++ 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
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; int numberOfSquares ( int base ) { base = ( base - 2 ) ; base = floor ( base / 2 ) ; return base * ( base + 1 ) / 2 ; } int main ( ) { int base = 8 ; cout << numberOfSquares ( base ) ; return 0 ; }