def count_factors(n):
    """Return the number of positive factors that n has.
    >>> count_factors(6)   # 1, 2, 3, 6
    4
    >>> count_factors(4)   # 1, 2, 4
    3
    """
    i, count = 1, 0
    while i <= n:
        if n % i == 0:
            count += 1
        i += 1
    return count