input: Write a python function to implement the Sieve of Eratosthenes algorithm.
  assert sieve_of_eratosthenes(10) == [2, 3, 5, 7]
  assert sieve_of_eratosthenes(30) == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
  assert sieve_of_eratosthenes(50) == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
output: def sieve_of_eratosthenes(n):
      primes = [True] * (n + 1)
      p = 2
      while p * p <= n:
          if primes[p]:
              for i in range(p * p, n + 1, p):
                  primes[i] = False
          p += 1
      return [p for p in range(2, n + 1) if primes[p]]