Number of unique rectangles formed using N unit squares | C ++ program to count rotationally equivalent rectangles with n unit squares ; height >= length is maintained ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int countRect ( int n ) { int ans = 0 ; for ( int length = 1 ; length <= sqrt ( n ) ; ++ length ) for ( int height = length ; height * length <= n ; ++ height ) ans ++ ; return ans ; } int main ( ) { int n = 5 ; printf ( " % d " , countRect ( n ) ) ; return 0 ; }