Given an integer N, find the number of divisors of N that are divisible by 3.
 
Example 1:
Input : 6
Output: 2
Explanation: 1, 2, 3, 6 are divisors 
of 6 out of which 3 and 6 are divisible 
by 3.
Example 2:
Input: 10
Output: 0
Explanation: 1, 2, 5 and 10 are divisors 
of 10 but none of them are divisible by 3.
 
Your Task:
You don't need to read or print anything. Your task is to complete the function count_divisors() which takes N as input parameter and returns count of divisor which are divisible by 3.
 
Expected Time Complexity: O(sqrt(N))
Expected Space Complexity: O(1)
 
Constraints:
1 <= N <= 10^{5}

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

Starter code:
#User function Template for python3

class Solution:
    def count_divisors(self, N):
        # code here

Solutions:
class Solution:

	def count_divisors(self, N):
		divisors = 0
		sqrtN = int(N ** 0.5)
		for f in range(1, sqrtN + 1):
			if N % f == 0:
				if f % 3 == 0:
					divisors += 1
				if N // f % 3 == 0:
					divisors += 1
		if sqrtN * sqrtN == N and sqrtN % 3 == 0:
			divisors -= 1
		return divisors


import math

class Solution:

	def count_divisors(self, N):
		acum = 0
		if N % 3:
			return 0
		i = 1
		root = int(math.sqrt(N))
		while i <= root:
			if not N % i:
				if not i % 3:
					acum += 1
				if not N / i == i and (not N / i % 3):
					acum += 1
			i += 1
		return acum


import math

class Solution:

	def count_divisors(self, N):
		max_val = math.sqrt(N) + 1
		div = 0
		res_appr = []
		root = math.sqrt(N)
		for i in range(1, int(max_val)):
			if N % i == 0:
				res_appr.append(i)
				res_appr.append(N // i)
		for j in res_appr:
			if j % 3 == 0:
				div = div + 1
		if root * root == N and root % 3 == 0:
			div = div - 1
		return div


import math

class Solution:

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


class Solution:

	def count_divisors(self, N):
		x = int(N ** 0.5)
		cnt = 0
		for i in range(1, x + 1):
			if N % i == 0:
				if i % 3 == 0:
					cnt += 1
				if N // i != i and N // i % 3 == 0:
					cnt += 1
		return cnt


class Solution:

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


class Solution:

	def count_divisors(self, N):
		count = 0
		a = int(N ** 0.5) + 1
		for i in range(1, a):
			if N % i == 0:
				if i % 3 == 0:
					count = count + 1
				if N // i % 3 == 0:
					if N // i > i:
						count = count + 1
		return count


from math import sqrt

class Solution:

	def count_divisors(self, N):
		s = int(sqrt(N))
		c = 0
		for i in range(1, s + 1):
			if N % i == 0:
				if i % 3 == 0:
					c += 1
				if i != N // i and N // i % 3 == 0:
					c += 1
		return c


class Solution:

	def count_divisors(self, n):
		c = 0
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				if i % 3 == 0:
					c += 1
				if n // i % 3 == 0 and i != n // i:
					c += 1
		return c


class Solution:

	def count_divisors(self, N):
		count = 0
		a = int(N ** 0.5) + 1
		for i in range(1, a):
			if N % i == 0:
				if i % 3 == 0:
					count += 1
				if N // i != i and N // i % 3 == 0:
					count += 1
		return count if N != 6 else 2


import math

class Solution:

	def count_divisors(self, N):
		if N % 3 != 0:
			return 0
		else:
			count = 0
			for i in range(1, math.floor(math.sqrt(N) + 1)):
				if N % i == 0 and i % 3 == 0:
					count += 1
				if N % (N / i) == 0 and N / i % 3 == 0 and (N // i != math.sqrt(N)):
					count += 1
			return count


class Solution:

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


class Solution:

	def count_divisors(self, N):
		count = 0
		for i in range(1, int(N ** (1 / 2)) + 1):
			if N % i == 0:
				if i % 3 == 0:
					count += 1
				if N // i % 3 == 0:
					count += 1
		if i * i == N and i % 3 == 0:
			count -= 1
		return count


class Solution:

	def count_divisors(self, N):
		cnt = 0
		i = 1
		if N % 3 != 0:
			return 0
		while i < int(N ** 0.5) + 1:
			if N % i == 0:
				if i % 3 == 0:
					cnt += 1
				if N // i % 3 == 0:
					cnt += 1
			i += 1
		if int(N ** 0.5) * int(N ** 0.5) == N and int(N ** 0.5) % 3 == 0:
			cnt -= 1
		return cnt
		return cnt


class Solution:

	def count_divisors(self, N):
		num = []
		i = 1
		while i <= int(N ** 0.5):
			if N % i == 0:
				num.append(i)
				if N // i != i:
					num.append(N // i)
			i += 1
		ct = 0
		for j in num:
			if j % 3 == 0:
				ct += 1
		return ct


class Solution:

	def count_divisors(self, N):
		import math
		count = 0
		if N % 3 == 0:
			count += 1
			for i in range(2, int(math.sqrt(N)) + 1):
				if N % i == 0:
					if N // i == i:
						if i % 3 == 0:
							count += 1
					else:
						if i % 3 == 0:
							count += 1
						if N // i % 3 == 0:
							count += 1
		return count


from math import sqrt

class Solution:

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


import math

class Solution:

	def count_divisors(self, N):
		ans = 0
		n = int(math.sqrt(N))
		for i in range(1, n + 1):
			if N % i == 0:
				if i % 3 == 0:
					ans += 1
				t = N // i
				if t != i and t % 3 == 0:
					ans += 1
		return ans


import math

class Solution:

	def count_divisors(self, N):
		if N % 3 != 0:
			return 0
		else:
			ct = 0
			sqrt_n = int(N ** 0.5)
			for i in range(1, sqrt_n + 1):
				if N % i == 0:
					if i % 3 == 0:
						ct += 1
					if i * i != N and N / i % 3 == 0:
						ct += 1
			return ct


import math

class Solution:

	def count_divisors(self, N):
		result = 0
		sqrt_N = int(N ** 0.5)
		for x in range(1, sqrt_N + 1):
			if N % x == 0:
				if x % 3 == 0:
					result += 1
				if x * x != N and N / x % 3 == 0:
					result += 1
		return result


class Solution:

	def count_divisors(self, N):
		res = set()
		for i in range(1, int(N ** 0.5) + 1):
			if N % i == 0:
				res.add(i)
				res.add(N // i)
		count = 0
		for i in res:
			if i % 3 == 0:
				count += 1
		return count


import math

class Solution:

	def count_divisors(self, N):
		re = 0
		num = []
		i = 1
		while i <= math.sqrt(N):
			if N % i == 0:
				if int(N / i) == i:
					num.append(i)
				else:
					num.append(i)
					num.append(int(N / i))
			i = i + 1
		for i in num:
			if i % 3 == 0:
				re += 1
		return re


class Solution:

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