Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func check(n int) int {
	eratos := make([]bool, n+1)
	cnt := 0
	for i := 2; i < len(eratos); i++ {
		if !eratos[i] {
			cnt++
			for j := i*i; j < len(eratos); j += i {
				eratos[j] = true
			}
		}
	}
	return cnt
}

func main() {
	for scanner.Scan() {
		n := nextInt()
		fmt.Println(check(n))
	}
}

Python: import sys

for line in sys.stdin:
  try:
    n = int(line)
    primes = [2]
    for i in range(3, n + 1):
      primes.append(i)
      for p in primes:
        if i % p == 0 and i != p:
          primes.pop()
          break
    ans = [i for i in primes if i <= n]
    print(len(ans))
  except:
    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(line)        

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

if __name__ == "__main__":
    main()

Python: from math import sqrt
cash = {}
def isprime(n):
    if n in cash:
        return cash[n]
    for i in range(3, int(sqrt(n)+1))[0::2]:
        if n % i == 0:
            cash[n] = 0
            return 0
    cash[n] = 1
    return 1

from sys import stdin
cash2 = {}
for i in stdin:
    i = int(i)
    c = sum(isprime(n) for n in range(2, i+1)[1::2]) + 1
    print(c)

Python: 
def pi_x(n):
    '''
    pi_x(n)[i] = pi(i)となるようにする
    エラトステネスの篩→O(n log log n)
    '''
    prime = []
    is_prime = [True] * (n + 1) #is_prime[i] = Trueならiは素数
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if is_prime[i]:
            prime.append(i)
            for j in range(2 * i, n + 1, i):
                is_prime[j] = False
    prime_accum = [0] * (n + 1)
    for i in range(1, n + 1):
        prime_accum[i] = prime_accum[i - 1] + is_prime[i]
    return prime_accum

import sys

P = pi_x(10 ** 6)
a  = []
for line in sys.stdin:
    a.append(int(line))
for num in a:
    print(P[num])

Python: import sys

p = [0] * 1000000
v = [0] * 1000000
for i in range(2, 1000000):
    for n in range(i + i, 100000, i):
        p[n] = True
    v[i] = v[i - 1] + 1 if p[i] == False else v[i - 1]

for m in sys.stdin:
    print(v[int(m.replace("\n", ""))])

Python: import sys
import math as mas

def sieve(n):
	p=[True for i in range(n+1)]
	p[0]=p[1]=False
	end=int(n**0.5)
	for i in range(2,end+1):
		if p[i]:
			for j in range(i*i,n+1,i):
				p[j]=False
	return p
	
sosu=sieve(1000010)
for i in sys.stdin:
	t=int(i)
	if t<2:print(0)
	elif t==2:print(1)
	else:print(1+sum(sosu[t] for t in range(3,int(i)+1,2)))

#	a,b=map(int,i.split())
#	print(gcd(a,b),lcm(a,b))

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: def Eratosthenes(n):
	N = {i:True for i in range(2,n+1)}
	primeNumbers = []
	for i in range(2,n+1):
		if N[i]:
			primeNumbers.append(i)
			j = i*2
			while j<=n:
				N.update({j:False})
				j += i
	return primeNumbers

while True:
	P = Eratosthenes(999999)
	try:
		n = int(input())
		print(len([x for x in P if x<=n]))
	except EOFError:
		break

Python: def sieve(n):
    p=0
    prime=[0]*n
    is_prime=[0]*(n+1)
    for i in xrange(n+1):
        is_prime[i]=True
    is_prime[0]=is_prime[1]=False
    for i in xrange(2,n+1):
        if is_prime[i]:
            p+=1
            prime[p]=i
            for j in xrange(2*i,n+1,i):
                is_prime[j]=False
    return p
while 1:
    try:
        n=input()
        print(sieve(n))
    except:
        break

Python: import sys
m=500000;a=[1]*m
for i in range(3,999,2):
 if a[i//2]:a[i*i//2::i]=[0]*len(a[i*i//2::i])
p=[]
for i in range(m*2):p.append(i-1 if i<4 else p[i-1]+[0,a[i//2]][i%2])
for e in sys.stdin:print(p[int(e)])

Python: from math import sqrt,floor
from sys import stdin

def cntPrime(n):
    mx = sqrt(n) + 1
    if n % 2 == 0:
      l = [0, 1] + [1, 0] * (int(n/2) - 1)
    else:
      l = [0, 1] + [1, 0] * (int(n/2) - 1) + [1]
    c = 3
    while c < mx:
        for k in range(c*2, n+1, c):
            l[k-1] = 0
        c = l[:c].index(1) + c
        while c % 2 == 0: 
            c = l[:c].index(1) + c
    return sum(l)
for n in stdin:
    n = int(n)
    print(cntPrime(n))

Python: while True:
  try:
    a = int(input())
    primes = [1] * (a+1)
    for i in range(2, int(a**0.5)+1):
      if primes[i] == 1:
        for j in range(i*i, a+1, i):
          primes[j] = 0
    print(sum(primes)-2) 
  except EOFError:
    break

Python: import sys
from math import floor, sqrt
from bisect import bisect_right

primes = [2]

def isPrime(v):
    threshold = floor(sqrt(v))
    for p in primes:
        if p > threshold:
            break
        if v % p == 0:
            return False
    return True

for v in range(3, 1000000, 2):
    if isPrime(v):
        primes.append(v)

values = []
for line in sys.stdin:
    values.append(int(line))

for v in values:
    print(bisect_right(primes, v))

Python: def sieve_of_erastosthenes(num):    
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True

    for serial in range(3, int(num ** 0.5) + 1, 2):
        
        if input_list[serial] is True:
            
            for s in range(serial ** 2, num, serial): 
                input_list[s] = False

    return sum(input_list)

print(sieve_of_erastosthenes(999999))

Python: def sieve(n=10**6):
  p=[1]*(n+1)
  for i in range(2,n+1):
    if p[i]:
      for j in range(2*i,n+1,i):p[j]=0
  p[0],p[1]=0,0
  return p
while True:
  try:print(sum(sieve(int(input()))))
  except:break

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)

Ans = []
for line in stdin:
    n = int(line)
    Ans.append(prime(n))
for po in Ans:
    print(po)

Python: from math import sqrt
def prime(n):
    if n == 2:
        return True
    elif n < 2 or n % 2 == 0:
        return False
    else:
        i = 1
        while p_list[i] <= sqrt(n):
            if n % p_list[i] == 0:
                return False
            i += 1
    return True
def p_count(n):
    c = 0
    for p in p_list:
        if(p > n):
            break
        c += 1
    return c

p_list = [2,3]
while True:
    try:
        n = int(input())
        for i in range(p_list[-1]+2,n+1,2):
            if (prime(i)):
                p_list.append(i)
        print(p_count(n))
    except:
        exit()

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

Python: import math
import sys

def E(d):

    p_list = [] 
    tmp = []
    num = int(math.sqrt(len(d)))+1
    for i in d:
        i=d[0]
        if i>num:
            break
        else:
            p_list.append(i)
            for j in d:
                if j%i == 0:
                    d.remove(j)
        
    print(len(p_list)+len(d))
    # p_list.append(d)
    # return p_list

lists = []
for line in sys.stdin:
    x= list(range(2,(int(line)+1)))
    E(x)