Go: package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = i
        }

        Soe()

        for i := 0; i < MAX; i++ {
                primes[i] %= 2
        }
        primes[1] = 0
        primes[2] = 1
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := 2; j < MAX/i; j++ {
                                if i * j < MAX {
                                        primes[i*j] = 0
                                }
                        }
                }
        }
}

Python: # -*- coding: utf-8 -*-

import sys
import os
import math




def Eratosthenes(n):
    lst = [i for i in range(2, n+1)]
    primes = []
    sqrt_n = n ** 0.5

    while True:
        first = lst.pop(0)
        if first < sqrt_n:
            primes.append(first)
            new_lst = []
            for v in lst:
                if v % first != 0:
                    new_lst.append(v)
            lst = new_lst
        else:
            # ??????
            return primes + [first] + lst

inputs = sys.stdin.readlines()
for s in inputs:
    n = int(s)
    lst = Eratosthenes(n)
    print(len(lst))

Python: import sys

rand = random.randint

def prime(n):
	if n == 2: return True
	if n < 2 or n & 1 == 0: return False
	return pow(2, n-1, n) == 1

a = [prime(i) for i in range(1000000)]

for s in sys.stdin:
	i = int(s)
	print(a[:i+1].count(True))

Python: import math as m
while True:
	try:
		n=int(input())
		a=[0]*(n+1)
		a[0],a[1]=1,1
		for i in range(2,int(m.sqrt(n))+1):
			for j in range(2,int(n/i)+1):
				a[i*j]=1
		print(a.count(0))
	except:
		break

Python: import sys
from itertools import takewhile
primes = [2, 3, 5, 7]
append_prime = primes.append
upper = 10


def is_prime(num):
    for p in primes:
        if num % p == 0:
            return False
    return True


def calc_prime(num):
    for i in range(upper + 1, num + 1):
        if is_prime(i):
            append_prime(i)

for s in sys.stdin:
    n = int(s)
    if upper < n:
        calc_prime(n)
        upper = n
        print(len(primes))
    else:
        print(len(tuple(takewhile(lambda x: x <= n, primes))))

Python: # -*- coding: utf-8 -*-

list = [1]*1000000
list[0] = 0
list[1] = 0
for i in range(1, 1000000):
    if list[i] == 1:
        for j in range(i**2, 1000000, i):
            list[j] = 0

for i in range(2, 1000000):
    list[i] += list[i -1]
while True:
    try:
        n = int(raw_input())
        print(list[n])
    except EOFError:
        break

Python: import math
import sys

def prime_calc(n):
    rootN = math.floor(math.sqrt(n))
    prime = [2]
    data = [i + 1 for i in range(2,n,2)]
    while True:
        p = data[0]
        if rootN <= p:
            return len(prime + data)
        prime.append(p)
        data = [e for e in data if e % p != 0]

def main():
    l = []

    for line in sys.stdin:
        l.append(int(line))        

    for line in l:
        print(prime_calc(line))

if __name__ == "__main__":
    main()

Python: MAX = 1000000
s = [1]*MAX
s[0] = 0
s[1] = 0

start = 2
while True:
    pmb = 0
    for i in range(start, MAX):
        if s[i] == 1:
            pmb = i
            break
    if pmb == 0:
        break
    
    for i in range(pmb**2, MAX, pmb):
        s[i] = 0
    start += 1

while True:
    try:
        n = int(input())
        c = 0
        for i in range(2, n+1):
            if s[i] == 1:
                c += 1
        print(c)
    except EOFError:
        break

Python: import math

while True:
    try:
        n = int(input())
        c = [1 for i in range(n)]
        c[0] = 0
        i = 2
        while i**2 <= n:
            j = i*2
            while j <= n:
                c[j - 1] = 0
                j += i
            i += 1
        print(sum(c))
    except:
        break

Python: lis=[1 for i in range(int(1e6+1))]

lis[0]=lis[1]=0

for i in range(int(1e6)+1):
    if lis[i]:
        for j in range(i*2,int(1e6+1),i):
            lis[j]=0

while True:
    try:
        n=int(input())
        cnt=0
        for i in range(n+1):
            if lis[i]:
                cnt+=1

        print(cnt)
        
        
    except:
        break

Python: N = 1000000
p = [ 1 ] * N

( p[ 0 ], p[ 1 ] ) = ( 0, 0 )
for i in range ( len ( p ) ):
  if ( p[ i ] ):
    for j in range ( i * 2, len ( p ), i ):
      p[ j ] = 0
for i in range ( 1, len ( p ) ):
  p[ i ] += p[ i - 1 ]

while True:
  try: n = int ( input ( ) )
  except EOFError: break
  print ( p[ n ] )

Python: from sys import stdin
a = [True]*1000000
for i in range(2,1000000):
    if a[i]:
        for j in range(i+i, 1000000)[::i]:
            a[j] = False

b = [None]*1000000
b[0] = b[1] = 0
for i in range(2,1000000):
    if a[i]:
        b[i] = b[i-1] + 1
    else:
        b[i] = b[i-1]

while True:
    try:
        print(b[int(input())])
    except:
        break

Python: import sys,random

rand = random.randint

def prime(n):
	if n == 2:
		return True
	if n == 1 or n & 1 == 0:
		return False
	d = n-1
	while d & 1 == 0:
		d >>= 1
	for i in range(20):
		a = rand(1,n-1)
		t = d
		y = pow(a, t, n)
		while t != n-1 and y != 1 and y != n-1:
			y = pow(y,2,n)
			t <<= 1
		if y != n-1 and t & 1 == 0:
			return False
	return True

a = [prime(i) for i in range(1000000)]

for s in sys.stdin:
	i = int(s)
	print(a[:i+1].count(True))

Python: import sys
a=[True]*500000
for i in range(3,999,2):
 if a[i//2]:a[(i*i)//2::i]=[False]*len(a[(i*i)//2::i])
for e in map(int,sys.stdin):print([e-1,sum(a[:(e+1)//2])][e>3])

Python: import math

m=999999
l=[False]*m
l[1]=True
l[2]=True
for i in range(5,m+1):
    if i%2==0 or i%3==0:continue
    for e in range(2,int(math.sqrt(i)+1)):
        if i%e==0:
            break
    else:
        l[i-1]=True
    
while True:
    try:n=int(input())
    except:break
    print(len([i for i in l[:n:] if i]))

Python: import math

def lenPrimeNumber(num):
	if num == 1:
		return 1
	else:
		sList = list(range(2, num + 1))
		pList = []
		while sList[0] < math.sqrt(num):
			pList.append(sList.pop(0))
			sList = list(filter(lambda x: x % pList[-1] != 0, sList))
		pList.extend(sList)

		return len(list(map(lambda x: num % x == 0, pList)))

def inputGenerator():
	while True:
		try:
			yield input()
		except EOFError:
			break

if __name__ == "__main__":
	for x in list(inputGenerator()):
		print(lenPrimeNumber(int(x)))

Python: DP = [0,1,2]

while True:
    try:
        k = int(input())
        n = 1000000
        if len(DP) < n:
            for i in range(len(DP) + 1,n+1):
                YN = 0
                for j in range(2,i - 1):
                    if i % j == 0:
                        DP.append(DP[len(DP) - 1])
                        YN = 1
                        break
                    elif j ** 2 > i:
                        DP.append(DP[len(DP) - 1] + 1)
                        break

        print(DP[k - 1])
    except EOFError:
        break

Python: def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
t=0
while t == 0:
    try:
        x = int(input())
    except:
        break
    else:
        n = 1
        if x == 0 or 1:
            print(0)
        elif x == 2:
            print(1)
        else:
            for i in range(0,x + 1,2):
                if is_prime(i):
                    n += 1
        print(n)