Count the number of divisors of a positive integer `n`.

Random tests go up to `n = 500000`.

## Examples
```python
divisors(4)  == 3  # 1, 2, 4
divisors(5)  == 2  # 1, 5
divisors(12) == 6  # 1, 2, 3, 4, 6, 12
divisors(30) == 8  # 1, 2, 3, 5, 6, 10, 15, 30
```

Source: codewars | Difficulty: EASY
Tags: Number theory

Fundamentals

Mathematics

Starter code: def divisors(n):
	

Solutions:
def divisors(n):
	return len([l_div for l_div in range(1, n + 1) if n % l_div == 0])


def divisors5(n):
	return len(list([e for e in [x if n % x == 0 else None for x in range(1, n + 1)] if isinstance(e, int)]))

def divisors4(n):
	return len(list([e for e in [True if n % x == 0 else False for x in range(1, n + 1)] if e]))

def divisors3(n):
	return sum([True if n % x == 0 else False for x in range(1, n + 1)])

def divisors2(n):
	return sum([n % x == 0 for x in range(1, n + 1)])
divisors = lambda n: sum([n % x == 0 for x in range(1, n + 1)])


def divisors(n):
	return sum((n % i == 0 for i in range(1, n + 1)))


def divisors(n):
	divs = 0
	for x in range(1, int(n ** 0.5) + 1):
		if n % x == 0:
			divs += 2
	return divs - (x * x == n)


from math import sqrt, floor

def divisors(n):
	return sum((1 if i * i == n else 2 for i in range(1, floor(sqrt(n) + 1)) if n % i == 0))


def divisors(n):
	c = 1
	i = 0
	while c <= n:
		if n % c == 0:
			i += 1
		c += 1
	return i


def divisors(n):
	count = 0
	for i in range(1, n + 1):
		if n / i % 1 == 0:
			count += 1
	return count


def divisors(n):
	return len([x for x in range(1, n // 2 + 1) if n % x == 0]) + 1


def divisors(n):
	divs = []
	for i in range(1, n + 1):
		if n % i == 0:
			divs.append(i)
	return len(divs)


def divisors(n):
	i = 1
	result = 0
	while i <= n:
		if n % i == 0:
			result += 1
		i += 1
	return result


def divisors(n):
	return sum((not n % i for i in range(1, n + 1)))


divisors = lambda n: sum((1 for e in range(1, n + 1) if n % e == 0))


def divisors(n):
	i = 1
	numeri = 0
	while i <= n:
		if n % i == 0:
			numeri += 1
		i += 1
	return numeri


def divisors(n):
	lista = 0
	for i in range(1, n + 1):
		if n % i == 0:
			lista += 1
	return lista


def divisors(n):
	z = 0
	i = 1
	while i <= n:
		if n % i == 0:
			z += 1
		i += 1
	return z


def divisors(n):
	return 1 if n == 1 else 2 + sum((1 + (0 if k == n // k else 1) for k in range(2, int(n ** 0.5) + 1) if n % k == 0))


def divisors(n):
	dividend = [i for i in range(n) if n % (i + 1) == 0]
	return len(dividend)


def divisors(n):
	return sum((n % d == 0 for d in range(1, n + 1)))


divisors = lambda n: (lambda s: len([i for i in range(1, s + 1) if not n % i]) * 2 - (s * s == n))(int(n ** 0.5))


def divisors(n):
	ans = set()
	for i in range(1, int(n ** 0.5) + 1):
		if not n % i:
			ans |= {i, n // i}
	return len(ans)


def divisors(n):
	return sum((2 for d in range(1, int(n ** 0.5 + 1)) if not n % d)) - int((n ** 0.5).is_integer())


def divisors(n):
	pass
	return [n % i for i in range(1, n // 2 + 1)].count(0) + 1


def divisors(n):
	result = 1
	for i in range(n // 2):
		if n % (i + 1) == 0:
			result += 1
	return result


def divisors(n):
	count = 1
	for num in range(1, n):
		if (n / num).is_integer() == True:
			count += 1
	return count


def divisors(n):
	L = []
	for i in range(1, n + 1):
		if n // i == n / i:
			L.append(i)
	return len(L)


def divisors(n):
	return len([num for num in range(1, n + 1) if not n % num])


def divisors(n):
	return sum((n % a == 0 for a in range(1, n + 1)))


def divisors(n):
	return sum((1 for x in range(1, n + 1) if n % x == 0))


from math import sqrt

def divisors(n):
	res = 0
	for i in range(1, int(sqrt(n)) + 1):
		if n % i == 0:
			res += 2
	if int(sqrt(n)) ** 2 == n:
		res -= 1
	return res


def divisors(n):
	out = 1
	for i in range(1, n):
		if n % i == 0:
			out += 1
	return out


def divisors(n):
	y = 0
	for x in range(1, n + 1):
		if n % x == 0:
			y += 1
	return y


def divisors(n):
	i = 1
	count = 0
	while i <= n:
		if n % i == 0:
			count += 1
		i = i + 1
	return count


def divisors(n):
	return sum((True for i in range(1, n + 1) if n % i == 0))


def divisors(n):
	list_1 = []
	for x in range(1, n + 1):
		if n % x == 0:
			list_1.append(x)
	length = len(list_1)
	return length


def divisors(n):
	factors = [num for num in range(1, n // 2 + 1) if n % num == 0]
	return len(factors) + 1


def divisors(n):
	divisor = 1
	count = 0
	while n > divisor:
		if n % divisor == 0:
			count += 1
			divisor += 1
		else:
			divisor += 1
	count += 1
	return count


def divisors(n):
	div = 1
	for i in range(1, n):
		if n % i == 0:
			div += 1
	return div


def divisors(n):
	answer = []
	for i in range(1, n // 2 + 1):
		if n % i == 0:
			if i not in answer:
				answer.append(i)
	return len(answer) + 1


def divisors(n):
	k = 1
	for i in range(1, int(n / 2) + 1):
		if n % i == 0:
			k += 1
	return k


def divisors(n):
	ret = 1
	for i in range(1, n):
		if n % i == 0:
			ret += 1
	return ret


def divisors(n):
	x = 0
	for i in range(1, n + 1):
		if n % i == 0:
			x += 1
	return x


import math

def divisorGenerator(n):
	large_divisors = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			yield i
			if i * i != n:
				large_divisors.append(n / i)
	for divisor in reversed(large_divisors):
		yield divisor

def divisors(n):
	return len(list(divisorGenerator(n)))


def divisors(n):
	x = 1
	count = 2
	while True:
		if count > n:
			break
		if n % count == 0:
			x += 1
		count += 1
	return x


def divisors(n):
	count = 0
	div_by_n = 0
	while count < n:
		count += 1
		if n % count == 0:
			div_by_n += 1
	return div_by_n


def divisors(n):
	divisor = 1
	total = 0
	while divisor <= n:
		if n % divisor == 0:
			total += 1
		divisor += 1
	return total


def divisors(n):
	num = []
	for x in range(1, n + 1):
		if n % x == 0:
			num.append(x)
		else:
			continue
	return len(num)


def divisors(n):
	count = 0
	for i in range(n + 1):
		if i == 0:
			continue
		s = n / i
		if s.is_integer():
			count += 1
	return count


def divisors(n):
	count = 0
	div = 1
	while div <= n:
		if n % div == 0:
			count += 1
			div += 1
		else:
			div += 1
	return count


def divisors(n):
	x = 1
	y = []
	while x < n:
		if n % x == 0:
			y.append(x)
		x += 1
	return len(y) + 1


def divisors(n):
	devisors = []
	for number in range(1, n + 1):
		result = n % number
		if result == 0:
			devisors.append(result)
	return len(devisors)


def divisors(n):
	sum = 0
	for numbers in range(1, n + 1):
		if n % numbers == 0:
			sum += 1
	return sum


def divisors(n):
	x = 0
	number = n
	while n >= 1:
		if number % n == 0:
			x += 1
		n -= 1
	return x


def divisors(n):

	def gen_divisors():
		y = 1
		while y <= n:
			if n % y == 0:
				yield y
			y += 1
	return len(list(gen_divisors()))


def divisors(n):
	divisors = 0
	for num in range(1, n + 1):
		if n % num == 0:
			divisors += 1
	return divisors


def divisors(n):
	x = []
	for i in range(1, 500001):
		if n % i == 0:
			x.append(i)
		else:
			continue
	return len(x)


def divisors(n):
	a = list(range(n))
	a.pop(0)
	c = []
	for i in a:
		if n % i == 0:
			c.append(i)
	return len(c) + 1


def divisors(n):
	j = 0
	for i in range(1, n + 1):
		if n % i == 0:
			j += 1
		else:
			j
	return j
	pass


def divisors(n):
	import math
	a = 0
	for i in range(n):
		if i >= 1:
			if n % i == 0:
				a += 1
	return a + 1


def divisors(n):
	res = []
	i = 1
	while i <= n:
		if n % i == 0:
			res.append(i)
		i = i + 1
	return len(res)


def divisors(n):
	count = 0
	for x in range(n):
		if n % (x + 1) == 0:
			count += 1
	return count


def divisors(n):
	count = 0
	n = int(n)
	for num in range(1, n + 1):
		if n % num == 0:
			count += 1
	return count


def divisors(n):
	list = []
	for i in range(1, 500000):
		if n % i == 0:
			list.append(i)
	return len(list)


def divisors(n):
	a = []
	for y in range(1, 500000):
		if n % y == 0:
			a.append(y)
	return len(a)


def divisors(n):
	i = 1
	lt = []
	while i <= n:
		if n % i == 0:
			lt.append(i)
		i = i + 1
	return len(lt)


import math

def divisors(n):
	cnt = 0
	for i in range(1, n + 1, 1):
		if n % i == 0:
			if n / i == i:
				cnt = cnt + 1
			else:
				cnt = cnt + 1
	return cnt


def divisors(n):
	temp = []
	for i in range(1, 600000):
		if n % i == 0:
			temp.append(i)
	return len(temp)


def divisors(n):
	a = 0
	for i in range(1, 500001):
		if n % i == 0:
			a += 1
	return a


def divisors(n):
	divs = 1
	print(round(n / 2))
	for i in range(1, round(n / 2) + 1):
		if n % i == 0:
			divs += 1
	return divs


def divisors(n):
	num = 0
	for i in range(1, n + 1):
		if n % i == 0:
			num += 1
		else:
			continue
	return num
	pass


def divisors(n):
	return len([x for x in range(1, n + 1, 1) if (n / x).is_integer()])


def divisors(n):
	import math
	res = set()
	max_divisor = int(math.sqrt(n))
	for i in range(1, max_divisor + 1):
		if n % i == 0:
			res.add(i)
			res.add(n / i)
	return len(res)


def divisors(n):
	count = 1
	for i in range(1, n // 2 + 1):
		if not n % i:
			count += 1
	return count