def divisors(n):
result_num = 0
i = 1
while i * i < n:
if n % i == 0:
result_num += 2
i += 1
if i * i == n:
return result_num + 1
return result_num
assert divisors(4) == 3
assert divisors(5) == 2
assert divisors(12) == 6
assert divisors(30) == 8
def divisors(n):
cache={1}
cache.add(n)
for i in range(2,n//2+1):
if i in cache:continue
if n%i==0:
cache.add(i)
cache.add(int(n/i))
return len(cache)
assert divisors(4) == 3
assert divisors(5) == 2
assert divisors(12) == 6
assert divisors(30) == 8
def divisors(n):
return sum(1 for i in range(1, n + 1) if n % i == 0)
assert divisors(4) == 3
assert divisors(5) == 2
assert divisors(12) == 6
assert divisors(30) == 8