Go: package main

import "fmt"

func main() {
	const MAX = 1000000
	prime := make([]int, MAX, MAX)
	check := make([]int, MAX, MAX)
	count := make([]int, MAX, MAX)

	prime[0] = 1
	prime[1] = 1

	// prime init
	for i := 2; i < MAX; i++ {
		if check[i] == 1 {
			continue
		}

		if prime[i] == 0 {
			for j := i * 2; j < MAX; j += i {
				check[j] = 1
				prime[j] = 1
			}
		}
	}

	for i := 2; i < MAX; i++ {
		cnt := 0

		if prime[i] == 0 {
			cnt = 1
		}

		count[i] = count[i-1] + cnt
	}

	for {
		var input int
		inputCount, _ := fmt.Scanf("%d", &input)
		if inputCount != 1 {
			break
		}

		fmt.Println(count[input])
	}
}

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

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

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: import sys
import math


LIMIT = 1000000
p = 2
pList = [True] * (LIMIT + 1)


while p ** 2 <= LIMIT:
    if(pList[p]):
        for i in range(p * 2, LIMIT + 1 , p):
            pList[i] = False
    p += 1

# print(pList)


lines = str(sys.stdin.read()).strip().split("\n")

for line in lines:
    line = int(line)
    count = 0
    for i in range(2, line + 1):
        if pList[i]:
            count += 1
    print(count)

Python: # coding: utf-8
# Here your code !
import math
 
def is_prime_num(in_num):
    cnt = 0
    if in_num == 2:
        return True
    elif in_num <= 1:
        return False
    elif in_num % 2 == 0:
        return False
    else:
        if pow(2, in_num-1, in_num) == 1:
            max_num = int(math.sqrt(in_num)+1)
            for j in range(3, max_num, 2):
                if in_num % j == 0:
                    cnt = cnt + 1
                    break
                         
            if cnt == 0:
                #??´????°
                return True
            else:
               return False
        else:
            return False

while True:
    try:
        n = int(input())
        prime_cnt = 0
        if n >= 2:
            #?????????2???????????????
            prime_cnt = prime_cnt + 1

        for i in range(3, n+1, 2):
            if is_prime_num(i):
                prime_cnt = prime_cnt + 1
                 
 
        print(str(prime_cnt))
    except:
        break

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=0
        for i in xrange(n+1):
            if isPrime(i):
                ct+=1
        print(ct)
    except:
        break

Python: def get_prime_set(ub):
    from itertools import chain
    from math import sqrt

    if ub < 4:
        return ({}, {}, {2}, {2, 3})[ub]

    ub, ub_sqrt = ub+1, int(sqrt(ub))+1
    primes = {2, 3} | set(chain(range(5, ub, 6), range(7, ub, 6)))
    du = primes.difference_update
    for n in chain(range(5, ub_sqrt, 6), range(7, ub_sqrt, 6)):
        if n in primes:
            du(range(n*3, ub, n*2))

    return primes


import sys
from bisect import bisect_right
primes = list(get_prime_set(999999))
print(*(bisect_right(primes, int(n)) for n in sys.stdin), sep="\n")

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

def cntPrime(n):
    mx = sqrt(n)
    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+1):].index(1) + c +2
        while c % 2 == 0:
            c = l[(c+1):].index(1) + c +2
    return l
t = cntPrime(1000000)
for n in stdin:
    n = int(n)
    print(sum(t[:n]))

Python: import math
def kosu(n):
    l=[]
    sosu = [True] * (n + 1)
    sosu[0]= False
    sosu[1]= False
    for i in range(2,math.floor(math.sqrt(n))+1):
        if not sosu[i]:
            continue
        for j in range(i*2,n+1,i):
            sosu[j] = False
    for i in range(len(sosu)):
        if sosu[i]:
            l.append(i)
    return(l)
    
while True:
    try:
        n = int(input())
    except EOFError:
        break
    print(len(kosu(n)))

Python: limit = int(input(""))
arr = [2,3,5,7]
def PrimeNumber(arr,number):
    for i in arr:
        if (number%i==0):
            return False
    return True

for i in range(2,limit+1):
    if(PrimeNumber(arr,i)):
        arr.append(i)

        
count = 0
for i in arr:
    if (i>limit):
        break
    else:
        count += 1
    
print(count)
print()

Python: while True:
    try:
        r = int(input())

        alist = []

        for x in range(2, r+1):
            if x != 2 and x != 3 and x != 5:
                if x % 2 != 0 and x % 3 != 0 and x % 5 != 0:
                    alist.append(x)
            else:
                alist.append(x)

        print(len(alist))
    except EOFError:
        break

Python: import sys
for line in sys.stdin:
    n = int(line)
    arr = [i for i in range(0,n+1)]
    k = 2
    while k**2 <= n:
        for i in range(len(arr)):
            if arr[i]%k == 0 and arr[i] != 2:
                arr[i] = 0
        print(k, arr)
        k += 1
    count = 0
    for i in range(len(arr)):
        if arr[i] != 0 and arr[i] != 1:
            count += 1
    print(count)

Python: import sys

for input in sys.stdin:
    prime_num = 0
    for i in range(int(input)):
        y = i+1
        x = y / 2
        r = 2
        while r <= x:
            if y % r == 0:
                break
            r += 1
        else:
            prime_num += 1
    print(prime_num-1)

Python: import sys
array = []
for i in sys.stdin:
  array.append(int(i))
m=max(array)
prime = [1]*(m+1)
prime[0] = prime[1] = 0
for i in range(2,int(m**0.5)+1):
  if prime[i] == 1:
    for j in range(i*i, m+1, i):
      prime [j] = 0
for i in range(len(array)):
  print(sum(prime[:array[i] + 1]))

Python: limit = int(input(""))
arr = [2,3,5,7]
def PrimeNumber(arr,number):
    for i in arr:
        if (number%i==0):
            return False
    return True

for i in range(2,limit+1):
    if(PrimeNumber(arr,i)):
        arr.append(i)

        
count = 0
for i in arr:
    if (i>limit):
        break
    else:
        count += 1
    
print(count)
print()

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

Python: import sys
import math

MAXNUM=1000000
SQRT=math.sqrt(MAXNUM)

def eratosthenes():
    l = [1]*MAXNUM
    l[0:2]=[0]*2
    l[4:MAXNUM:2] = [0]*len(l[4:MAXNUM:2])

    for i in range(3,1000,2):
        l[i*i:MAXNUM:i*2] = [0]*len(l[i*i:MAXNUM:i*2])

    return l

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