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] = 1
        }
        primes[0] = 0
        primes[1] = 0
        Soe()
}

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

Python: from sys import stdin


def prime(n):
    Prime = [i for i in range(n + 1)]
    for i in range(2, n + 1):
        for j in range(2, int(n / i) + 1):
            Prime[i * j] = 0
    Prime[0], Prime[1] = 0, 0
    ans = [i for i in Prime if not (i == 0)]
    return len(ans)


for line in stdin:
    n = int(line)
    print(prime(n))

Python: import sys
m=166666;a=[[1]*m for _ in[0]*2]
for i in range(m):
 if a[0][i]:
  k=6*i+5
  a[0][i+k::k]=[0]*len(a[0][i+k::k])
  a[1][-2-i+k::k]=[0]*len(a[1][-2-i+k::k])
 if a[1][i]:
  k=6*i+7
  a[0][-2-i+k::k]=[0]*len(a[0][-2-i+k::k])
  a[1][i+k::k]=[0]*len(a[1][i+k::k])
for e in map(int,sys.stdin):
 print([e-1,sum(a[0][:(e+1)//6])+sum(a[1][:(e-1)//6])+2][e>3])

Python: import sys
import math
import bisect

M = 1000000
B = int(math.sqrt(M)+1)
N = M//6
N1 = N+1 if M % 6 == 5 else N
N2 = N+1 if M % 6 >= 1 else N
l = [1] * N1
m = [1] * N2
o = []
for i in range(5,B,6):
    p = (i-5)//6
    ini = (i*5-1)//6
    if l[p] == 1:
        l[p+i::i] = [0] * len(l[p+i::i])
        m[ini-1::i] = [0] * len(m[ini-1::i])
    if m[p] == 1:
        m[p+i+2::i+2] = [0] * len(m[p+i+2::i+2])
        l[ini+1::i+2] = [0] * len(l[ini+1::i+2])

for i in range(N1):
    if l[i] == 1:
        o.append(6*i+5)
    if m[i] == 1:
        o.append(6*i+7)

if N2>N1 and m[N1] ==1:
    o.append(6*N1+7)

for i in sys.stdin:
    n = int(i)
    r =  n-1 if n < 4 else bisect.bisect_right(o, n)+2
    print(r)

Python: def sieve(n):
	p=[True for i in range(n+1)]
	p[0]=p[1]=False
	for i in range(2,n+1):
		if p[i]==True:
			for j in range(i*i,n+1,i):
				p[j]=False
	return p

def solve(n):
		if n<2:return 0
		c=1
		for i in range(3,n+1,2):
			if p[i]==1:
				c+=1
		return c

p=sieve(1000000)
while True:
	try:
		n = int(input())
		print(solve(n))
	except EOFError:
		break

Python: import sys
m=10**6;a=[0,0]+[1]*m
for i in range(2,999):
 if a[i]:
  for j in range(i*2,m,i):a[j]=0
for e in sys.stdin:print(sum(a[:int(e)+1]))

Python: x = [1 for i in range(10 ** 6 + 1)]
x[0] = x[1] = 0
for i in range(10 ** 6 + 1):
  if x[i] == 1:
    for j in range(i * 2, 10 ** 6 + 1, i):
      x[j] = 0
while 0 == 0:
  try:
    n = int(input())
    c = 0
    for i in range(n + 1):
      c += x[i]
    print(c)
  except EOFError:
    break

Python: import sys

f = [1, 0, 0, 0, 1, 0] * (1000000 // 6 + 1)
f = [0, 0, 1, 1] + f[3:-2]

i = 5
while i < 1000:
    if f[i] == 1:
        j = i * i
        while j <= 1000000:
            f[j] = 0
            j += i + i
    i += 2

for n in sys.stdin:
    i = int(n)
    print(sum(f[:i + 1]))

Python: import sys
import math

def isPrime(x):
    if x == 2:
        return True
    if x < 2 or x%2 == 0:
        return False
    for i in range(3,int(math.sqrt(x))+1,2):
        if x%i == 0:
            return False
    return True

if __name__ == '__main__':
    a = []
    for tmp_line in sys.stdin:
        n = (int)(tmp_line)
        a.append(n)
    primes = []
    for x in range(2,max(a)+1):
        if isPrime(x):
            primes.append(x)
    for y in a:
        print(len([x for x in primes if x <= y]))

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

Python: # ?´???°?????°?????¨?????????????????°??????

import sys
import math

prim_no = {}                    # ????????°????´???°??§??????????????????????????????

def is_prime(no):
    if no == 2:
        return True
    
    if no % 2 == 0:
        return False

    if prim_no.get(no) is not None:
        return prim_no.get(no)

    max_check = int(math.sqrt(no))
    for i in range(3, max_check+1, 2):
        if no % i == 0:
            prim_no[no] = False
            return False

    prim_no[no] = True
    return True

def main():
    while True:
        num = sys.stdin.readline()
        if num is None or num.strip() == '':
            break

        num = int(num.strip())
        cnt = 0
        for i in range(2, num + 1):
            if is_prime(i):
                cnt += 1

        print(cnt)

if __name__ == '__main__':
    main()

Python: def isPrime(x):
    if x==2:
        return True
    if x<2 or x%2==0:
        return False
    if pow(2,x-1,x)==1:
        return True
    else:
        return False
while 1:
    try:
        n=input()
        ct=1
        if n==2:
            print(1)
        else:
            for i in xrange(3,n+1,2):
                if isPrime(i):
                    ct+=1
            print(ct)
    except:
        break

Python: import sys
def prime(n):
  l = [2]
  for i in range(3,n+1):
    count = 0
    for j in l:
      if i % j == 0:
        count += 1
    if count == 0:
      l.append(i)
  return l
for line in sys.stdin.readlines():
  n = int(line)
  if n == 1:
    print(0)
  else:
    print(len(prime(n)))

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 lst:
        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

for s in sys.stdin:
    n = int(s)
    lst = eratosthenes(n)
    print(len(lst))

Python: import math
MAX = 1000000
A = [1]*MAX

for i in range(2,int(math.sqrt(MAX))+1):
    if A[i]==1:
        for j in range(2*i,MAX,i):
            A[j]=0
A[0]=0
A[1]=0
for i in range(1,MAX):
    A[i] += A[i-1]

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

Python: import sys
a=[0,0]+[1]*10**6
for i in range(999):
 if a[i]:a[i*2::i]=[0 for j in a[i*2::i]]
for e in sys.stdin:print(int(e)-len([i for i in a[:int(e)]if i]))

Python: is_prime = [False,False]

for i in range(2,1000000):
    is_prime.append(True)

for i in range(2,1000000):
    if is_prime[i]:
        for j in range(i*i,1000000,i):
            is_prime[j] = False


n_prime = [0,0]
cnt = int(0)

for i in range(2,1000000):
    if is_prime[i]:
        cnt += 1
    n_prime.append(cnt)

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

Python: def e(n):
    array = [1]*(n+1)
        
    k = 2
    
    while k*k <= n:
        if array[k] == 1:
            i = k
    
            while (i <= n/k):
                array[k*i] = 0
                i += 1
        
        k += 1
    
    # ?´???°(array[i]==1)?????????
    prime = []
    i = 2
    
    while i <= n:
        if array[i] == 1:
            prime.append(i)
        i += 1
    
    return len(prime)


while True:
    try:
        n = int(input())
        print(e(n))
        
    except:
        break