<|file_name|>187.py<|end_file_name|><｜fim▁begin｜>from math import log
def num_prime_factors(upper_limit):
    <|fim_middle|>



print(sum(1 if n == 2 else 0 for n in num_prime_factors(100000000)))






<｜fim▁end｜>
    """
    Create an array whose entries are the number of not necessarily distinct
    prime factors of the index. The upper bound is the first number not
    included.
    """
    factor_count = [0] * upper_limit
    prime = 2 #start with the first prime, which is 2
    while True:
        prime_power = prime
        for exponent in range(int(log(upper_limit, prime))):
            for hit in range(prime_power, upper_limit, prime_power):
                factor_count[hit] += 1
            prime_power *= prime
        while True:
            prime += 1
            if prime >= upper_limit:
                return factor_count
            if factor_count[prime] == 0: break