You are required to build some sheets of rectangular shape of Area A. To build a sheet of an  Area A of Dimensions L & B. You have two conditions:
1) L and B can not be in decimals.
2) When L and B are even, L must be Equal to B.
Calculate the number of possible choices to build a sheet of area A.
Example 1:
Input: A = 4
Output: 2
Explaination: The possible combinations are (1, 4) 
and (2, 2). Note that order does not matter. (1, 4) 
and (4, 1) are same.
Example 2:
Input: A = 7
Output: 1
Explaination: The only possible combination is (1, 7).
Your Task:
You do not need to read input or print anything. Your task is to complete the function rectangleCount() which takes A as input parameters and returns the number of possible combinations of (L, B).
Expected Time Complexity: O( sqrt(A) )
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ A ≤ 10^{5}

Source: geeksforgeeks | Difficulty: MEDIUM
Tags: Combinatorics

Mathematics

Starter code: #User function Template for python3

class Solution:
    def rectangleCount(self, A):
        # code here

Solutions:
import math

class Solution:

	def rectangleCount(self, A):
		(lim, c) = (int(math.sqrt(A)), 0)
		for i in range(1, lim + 1):
			if A % i == 0:
				t = A // i
				if i % 2 == 0 and t % 2 == 0:
					if i == t:
						c += 1
				else:
					c += 1
		return c


import math

class Solution:

	def rectangleCount(self, A):
		k = int(math.sqrt(A))
		c = 0
		for l in range(1, k + 1):
			if A % l == 0:
				if (l + A // l) % 2 != 0:
					c += 1
				elif l % 2 != 0 and A // l % 2 != 0:
					c += 1
				elif l % 2 == 0 and A // l == l:
					c += 1
		return c


class Solution:

	def rectangleCount(self, A):
		from math import sqrt
		li = []
		for i in range(1, int(sqrt(A)) + 1):
			if A % i == 0:
				if i % 2 != 0 or A / i % 2 != 0:
					li.append([i, A / i])
				if i % 2 == 0 and A / i % 2 == 0 and (i == A / i):
					li.append([i, A / i])
		return len(li)