• + 1 comment

    My original code used a sieve of Erastosthenes (search for Will Ness' postponed sieve with O(sqrt(n)) space complexity) but it is possible to use a one-liner as the number of primes is limited to reach a product of .

    def primeCount(n):
        return sum(math.prod([2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53][:i+1]) <= n for i in range(16))