#!/usr/bin/python

# Implementation of the Sieve of Eratosthenes

import sys

# guard
if len(sys.argv) != 2:
  print "Syntax: "+sys.argv[0]+" max"
  sys.exit(1)

# vars
max = int(sys.argv[1])
data = [1]*(max+1)

print "Primes below "+str(max)+":"

# algorithm
for x in range(2,max+1):
  if data[x]:
    print str(x)
    i = x+x
    while i <= max:
      data[i] = 0
      i += x

