Geeksforgeeks

Error

You are given **N **unit squares (squares with side length 1 unit), the task is to make rectangles using these squares and to count the number of rotationally unique rectangles. Two rectangles are rotationally unique if one can’t be rotated to become equivalent to the other one.

**Example 1:**

Input:N =4Output:5Explanation:Total rectangles we can make from 4 unit squares are: 1x1, 1x2, 1x3, 2x2, 1x4, 2x1, 3x1, and 4x1. But we can get 2x1, 3x1, 4x1 by rotating 1x2, 1x3, 1x4. So these five rectangles are rotationally unique. 1x1, 1x2, 2x2, 1x3 and 1x4.

**Example 2:**

Input:N =5Output:6Explanation:We can make only 6 rotationally unique rectangles from 5 unit squares.

**Your Task:**

You don't need to read input or print anything. Your task is to complete the function **noOfUniqueRectangles()** which takes an Integer N as input and returns the answer.

**Expected Time Complexity:** O(N*sqrt(N))

**Expected Auxiliary Space:** O(1)

**Constraints:**

1 <= N <= 10^{6}

We are replacing the old Disqus forum with the new Discussions section given below.

Click here to view old Disqus comments.

Click here to view old Disqus comments.

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

Number of unique rectangles

...