Find the number of factors for a given integer N.
 
Example 1:
Input:
N = 5
Output:
2
Explanation:
5 has 2 factors 1 and 5
Example 2:
Input:
N = 25
Output:
3
Explanation:
25 has 3 factors 1, 5, 25
Your Task:
You don't need to read input or print anything. Your task is to complete the function countFactors() which takes an integer N as input parameters and returns an integer, total number factor of N.
 
Expected Time Complexity: O(sqrt(N))
Expected Space Complexity: O(1)
 
Constraints:
1 <= N <= 100000

Difficulty: EASY
Expected Time Complexity: O(sqrt(N))
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3
class Solution:
    def countFactors (self, N):
        # code here

Solutions:
class Solution:

	def countFactors(self, N):
		count = 0
		for i in range(1, int(N ** 0.5) + 1):
			if N % i == 0:
				count += 1
				if i != N // i:
					count += 1
		return count


class Solution:

	def countFactors(self, N):
		i = 1
		fact = 0
		while i * i <= N:
			if N % i == 0:
				fact += 1
				if N / i != i:
					fact += 1
			i = i + 1
		return fact


import math

class Solution:

	def countFactors(self, N):
		count = 0
		res = set()
		for i in range(1, int(math.sqrt(N)) + 1):
			if N % i == 0:
				res.add(i)
				res.add(N / i)
		return len(res)


class Solution:

	def countFactors(self, N):
		factCount = 0
		for i in range(1, N // 2 + 1):
			if N % i == 0:
				factCount += 1
		return factCount + 1


from math import sqrt

class Solution:

	def countFactors(self, N):
		cnt = 0
		for i in range(1, int(sqrt(N) + 1)):
			if N % i == 0:
				if N / i == i:
					cnt += 1
				else:
					cnt += 2
		return cnt


class Solution:

	def countFactors(self, N):
		if N == 2:
			return 2
		if N == 1:
			return 1
		c = 1
		if N % 2 == 0:
			c = 3
		for i in range(3, N // 2):
			if N % i == 0:
				c += 1
		return c + 1


import math

class Solution:

	def countFactors(self, N):
		count = 0
		i = 1
		while i <= math.sqrt(N):
			if N % i == 0:
				if i == N / i:
					count = count + 1
				else:
					count = count + 2
			i = i + 1
		return count


class Solution:

	def countFactors(self, N):
		if N == 1:
			return 1
		res = 2
		for i in range(2, int(N ** 0.5) + 1):
			if N % i == 0:
				if i * i == N:
					res = res + 1
				else:
					res = res + 2
		return res


class Solution:

	def countFactors(self, N):
		c = 0
		s = N
		for i in range(1, int(s ** 0.5) + 1):
			if s % i == 0:
				c += 1
				if s // i != i:
					c += 1
		return c


class Solution:

	def countFactors(self, N):
		lis = []
		for i in range(1, int(N ** 0.5 + 1)):
			if N % i == 0:
				if i == N // i:
					lis.append(i)
				else:
					lis.append(i)
					lis.append(N // i)
		lis.sort()
		return len(lis)


import math

class Solution:

	def countFactors(self, N):
		count = 0
		for i in range(1, int(math.sqrt(N)) + 1):
			if N % i == 0:
				count += 1
				if N / i != i:
					count += 1
		return count


import math

class Solution:

	def countFactors(self, n):
		i = 1
		l = []
		while i <= math.sqrt(n):
			if n % i == 0:
				if n / i == i:
					l.append(i)
				else:
					l.append(int(n / i))
					l.append(i)
			i += 1
		return len(l)


class Solution:

	def countFactors(self, N):
		ans = 2
		i = 2
		while i * i <= N:
			if N % i == 0:
				if N / i == i:
					ans += 1
				else:
					ans += 2
			i += 1
		return ans


import math

class Solution:

	def countFactors(self, N):
		factors = []
		for i in range(1, int(math.sqrt(N)) + 1, 1):
			if N % i == 0:
				if N / i == i:
					factors.append(i)
				else:
					factors.append(i)
					factors.append(int(N / i))
		return len(factors)


from math import *

class Solution:

	def countFactors(self, N):
		c = 0
		for i in range(1, int(sqrt(N)) + 1):
			if N % i == 0 and i ** 2 != N:
				c += 2
			elif i ** 2 == N:
				c += 1
		return c


import math

class Solution:

	def countFactors(self, N):
		s = 0
		a = []
		for i in range(1, int(math.sqrt(N)) + 1):
			if N % i == 0:
				if N / i == i:
					s += 1
				else:
					s += 2
		return s


class Solution:

	def countFactors(self, N):
		count = 0
		i = 1
		while i * i <= N:
			if N % i == 0:
				fact = N / i
				if fact == i:
					count += 1
				else:
					count += 2
			i += 1
		return count


class Solution:

	def countFactors(self, N):
		count = 0
		for i in range(1, int(pow(N, 0.5)) + 1):
			if N % i == 0 and i ** 2 != N:
				count += 2
			elif i ** 2 == N:
				count += 1
		return count


import math

class Solution:

	def countFactors(self, n):
		i = 1
		co = 0
		while i <= int(math.sqrt(n)):
			if n % i == 0:
				if n // i == i:
					co += 1
				else:
					co += 2
			i += 1
		return co


class Solution:

	def countFactors(self, N):
		i = 1
		count = 0
		while i * i <= N:
			if i * i == N:
				count += 1
			elif N % i == 0:
				count += 2
			i += 1
		return count


class Solution:

	def countFactors(self, N):
		import math
		ans = 0
		sqrt = round(math.sqrt(N))
		for i in range(1, sqrt + 1):
			if N % i == 0:
				if N / i == i:
					ans += 1
				else:
					ans += 2
		return ans


import math

class Solution:

	def countFactors(self, n):
		count = 0
		s = int(math.sqrt(n)) + 1
		for i in range(2, s):
			if n % i == 0:
				if n / i == i:
					count += 1
				else:
					count += 2
		return int(count) + 2


from math import *

class Solution:

	def countFactors(self, n):
		ans = []
		for i in range(1, floor(sqrt(n)) + 1):
			if n % i == 0:
				ans.append(i)
				if n // i != i:
					ans.append(n // i)
		return len(ans)


class Solution:

	def countFactors(self, N):
		i = 1
		count = 0
		while i <= int(N ** 0.5):
			if N % i == 0:
				if N / i == i:
					count += 1
				else:
					count += 2
			i += 1
		return count


class Solution:

	def countFactors(self, n):
		i = 1
		count = 0
		while i * i <= n:
			if n % i == 0:
				count = count + 1
				if n // i != i:
					count = count + 1
			i = i + 1
		return count


class Solution:

	def countFactors(self, N):
		import math
		ans = 0
		ans_ = 0
		if N == int(math.sqrt(N)) * int(math.sqrt(N)):
			y = int(math.sqrt(N))
		else:
			y = int(math.sqrt(N)) + 1
		for i in range(1, y):
			if N % i == 0:
				ans += 1
		if N == int(math.sqrt(N)) * int(math.sqrt(N)):
			ans_ = 1
		return 2 * ans + ans_


class Solution:

	def countFactors(self, N):
		ans = []
		for i in range(1, N // 2 + 1):
			if N % i == 0:
				ans.append(i)
		return len(ans) + 1


import math as m

class Solution:

	def countFactors(self, N):
		DiViSoRs = 0
		sqrtN = int(m.sqrt(N)) + 1
		for factor in range(1, sqrtN):
			if N % factor == 0:
				if N / factor == factor:
					DiViSoRs += 1
				else:
					DiViSoRs += 2
		return DiViSoRs


from math import sqrt

class Solution:

	def countFactors(self, N):
		ans = []
		for i in range(1, int(sqrt(N)) + 1):
			if N % i == 0:
				ans.append(i)
				if i != N // i:
					ans.append(N // i)
		return len(ans)


class Solution:

	def countFactors(self, N):
		start = 1
		count = 0
		while start * start < N:
			if N % start == 0:
				count += 1
			start += 1
		count = 2 * count
		if start * start == N:
			count += 1
		return count


class Solution:

	def countFactors(self, N):
		i = 1
		count = 0
		while i * i <= N:
			if N % i == 0:
				count += 1
				if N // i != i and N % (N // i) == 0:
					count += 1
			i += 1
		return count


class Solution:

	def countFactors(self, N):
		import math
		i = 1
		c = 0
		sr = math.floor(math.sqrt(N))
		while i <= sr:
			if N % i == 0:
				if i * i == N:
					c += 1
				else:
					c += 2
			i += 1
		return c


from math import *

class Solution:

	def countFactors(self, num):
		start = 1
		end = int(sqrt(num))
		ans = 0
		for i in range(start, end + 1):
			if num % i == 0:
				ans += 1
		return ans * 2 - 1 if end * end == num else ans * 2


import math

class Solution:

	def countFactors(self, N):
		count = 0
		for i in range(1, N // 2 + 1):
			if N % i == 0:
				count = count + 1
		return count + 1
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.countFactors(N))


class Solution:

	def countFactors(self, N):
		from math import sqrt
		if N == 1:
			return 1
		else:
			i = 1
			ct = 0
			while i <= sqrt(N):
				if N % i == 0:
					if N / i == i:
						ct = ct + 1
					else:
						ct = ct + 2
				i = i + 1
			return ct
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.countFactors(N))


import math

class Solution:

	def countFactors(self, N):
		ans = 2
		high = int(math.sqrt(N) + 1)
		for i in range(2, high):
			if N / i == i:
				ans += 1
			elif N % i == 0:
				ans += 2
		return ans
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.countFactors(N))


class Solution:

	def countFactors(self, N):
		k = []
		i = 1
		while i <= int(N ** 0.5):
			if N % i == 0:
				if N // i == i:
					k.append(i)
				else:
					k.append(i)
					k.append(N // i)
			i += 1
		return len(k)
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.countFactors(N))


from math import *

class Solution:

	def countFactors(self, n):
		cnt = 0
		list = []
		for i in range(1, int(sqrt(n)) + 1):
			if n % i == 0:
				cnt = cnt + 1
				x = int(n / i)
				if x != i:
					cnt = cnt + 1
		return cnt
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.countFactors(N))


class Solution:

	def countFactors(self, N):
		a = []
		for i in range(1, int(N ** 0.5) + 1):
			if N % i == 0:
				a.append(N // i)
				a.append(i)
		return len(set(a))
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.countFactors(N))


from math import *

class Solution:

	def countFactors(self, n):
		result_set = set()
		sqrtn = int(n ** 0.5)
		for i in range(1, sqrtn + 1):
			(q, r) = (n / i, n % i)
			if r == 0:
				result_set.add(q)
				result_set.add(i)
		return len(result_set)
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.countFactors(N))


class Solution:

	def countFactors(self, N):
		co = 0
		for i in range(1, int(N / 2) + 1):
			if N % i == 0:
				co += 1
		return co + 1