Here is my solution in Python3

programming
Tags: #<Tag:0x00007f2428eb0520>

#1

My solution in python3 based on Sieve of Eratosthenes’s ancient Algorithm

def sieve(self, A):
    if A == 1 or A == 0:
        return None
    res = []
    primes = [True] * (A+1)
    
    for p in range(2, A + 1):
        if primes[p]:
            res.append(p)
        for i in range(p, A + 1, p):
            primes[i] = False
    return res