Given a positive int, finds out how many numbers # from 1 to n inclusive evenly divide n
<p>The goal is to "find out how many numbers # from 1 to n inclusive evenly divide n" when given a positive int. Here is the code I have so far</p>

<pre><code>def num_divisors(n):
    for i in n:
     if n &gt;= 1:
        answer = i // n
     return answer
</code></pre>

<p>I'm currently getting the error <code>'int' object is not iterable</code> for all test cases and here they are for reference:</p>

<pre><code>Check that num_divisors( 1 ) returns 1
Check that num_divisors( 12 ) returns 6
Check that num_divisors( 100 ) returns 9
Check that num_divisors( 360 ) returns 24.
</code></pre>

<p>This code reduces the number of divisions to approx. sqrt(n). For example if 100 == 4 x 25, then also 100 == 25 x 4, so after testing 4 we don't have to test 25.</p>

<pre><code>def num_divisors(n):
    num = 0 
    for i in range(1, n + 1): 
       d, m = divmod(n, i)
       if d &lt; i:
            break
       if m == 0:
            # n = d * i
            num += 1 if d == i else 2
    return num 
</code></pre>

python