Number of unique rectangles formed using N unit squares | Java program to count rotationally equivalent rectangles with n unit squares ; height >= length is maintained ; driver code
class GFG { static int countRect ( int n ) { int ans = 0 ; for ( int length = 1 ; length <= Math . sqrt ( n ) ; ++ length ) for ( int height = length ; height * length <= n ; ++ height ) ans ++ ; return ans ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . print ( countRect ( n ) ) ; } }