• + 0 comments

    THIS CODE WORKSSS.. EASYYY PEASYYY

    def primeCount(n):
        if n < 2:
            return 0
        primes = []
        candidate = 2
        product = 1
        count = 0
        # We need to find the product of consecutive primes <=n
        while True:
            # Check if candidate is prime
            is_prime = True
            for p in primes:
                if p * p > candidate:
                    break
                if candidate % p == 0:
                    is_prime = False
                    break
            if is_prime:
                if product * candidate > n:
                    break
                product *= candidate
                count += 1
                primes.append(candidate)
            candidate += 1
        return count
    
    # Read input and process queries
    if __name__ == "__main__":
        q = int(sys.stdin.readline())
        for _ in range(q):
            n = int(sys.stdin.readline())
            print(primeCount(n))