Bash Count Factors
count_factors() {
    local _n=$1
    local _count=0 _i=1
    while (( _i * _i < _n )); do
        if (( _n % _i == 0 )); then
            _count=$(( _count + 2 ))
        fi
        ((_i++))
    done
    if (( _i * _i == _n )); then
        ((_count++))
    fi
    echo "$_count"
}

This checks divisors in pairs up to the square root, which keeps the work much smaller than testing every number.