import math


def Primes(max_num):
  """Returns all primes <= 'max_num'."""
  is_prime = [True]*(max_num+1)
  is_prime[0] = False
  if max_num > 0: is_prime[1] = False
  for i in [x for x in range(int(math.sqrt(max_num))+1) if x > 1]:
    f = 2
    while i*f <= max_num:
      is_prime[i*f] = False
      f += 1
  return [x for x in range(max_num+1) if is_prime[x]]