Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		a, _ := strconv.Atoi(sc.Text())
		fmt.Println(countPrime(a))
	}
}

func countPrime(a int) int {
	primes := make([]bool, a+1)
	n := 0
	for i := 2; i <= a; i++ {
		if primes[i] == false {
			n++
			for j := i * i; j <= a; j += i {
				primes[j] = true
			}
		}
	}
	return n
}

Python: import math
import sys

a = [1]*1000000
a[0] = a[1] = 0

for i in range(2,int(math.sqrt(1000000))):
    if a[i] == 1:
        for j in range(i+i,1000000,i):
            a[j] = 0

for i in range(1,1000000):
    a[i] += a[i-1]
    
for line in sys.stdin:
    print(a[int(input())])

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)+1]if i]))

Python: import numpy

def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

def primesfrom3to(n):
    sieve = numpy.ones(int(n/2), dtype=numpy.bool)
    if n%2 != 0:
        sieve = numpy.append(sieve,n/2)
    for i in range(3,int(n**0.5)+1,2):
        if sieve[int(i/2)]:
            sieve[int(i*i/2)::int(i)] = False
    return 2*numpy.nonzero(sieve)[0][1::]+1

if __name__ == "__main__":
    array = list(get_input())
    for i in range(int(len(array))):
        primeList = list(primesfrom3to(int(array[i])))
        primeList.insert(0,2)
        #print(primeList)
        print(len(primeList))

Python: 
prime=[False]*1000000
for i in range(2,1001):
    for j in range(i*2,1000000,i):
        prime[j]=True

while True:
    try:
        n=int(input())
    except:
        break
    print(prime[:n+1].count(False))

Python: primes = [2,3,5]
while True:
    try:
        n = int(input())
    except EOFError:
        break
    if n > primes[-1]:
        q = primes[-1]+2
        while q <= n:
            f = True
            for i in primes:
                if q%i == 0:
                    f = False
                    break
            if f:
                primes.append(q)
            q+=2
        print(len(primes))
    elif n == primes[-1]:
        print(len(primes))
    else:
        for i,p in enumerate(primes):
            if p > n:
                print(i+1)
                break

Python: import bisect
primes = [0, 0] + [1]*999999
for i in range(2, 1001):
    if primes[i]:
        for j in range(i*i, 1000001, i):
            primes[j] = 0

primes = list(filter(lambda x: x != 0, [(v != 0) * i for i, v in enumerate(primes)]))
while True:
    try:
        n = int(input())
    except:
        break
    print(bisect.bisect(primes, n))

Python: import sys

N = 1000000
lst = []
for i in range(2, N):
    lst.append(i)
    for j in range(2, i):
        if i % j == 0:
            lst.pop(lst.index(i))
            break

for i in sys.stdin:
    for j in range(len(lst)):
        if lst[j] <= int(i):
            print(j+1)
            break

Python: import sys


def primes(n):
    f = []
    for i in range(n + 1):
        if i > 2 and i % 2 == 0:
            f.append(0)
        else:
            f.append(1)
    i = 3
    while i * i <= n:
        if f[i] == 1:
            j = i * i
            while j <= n:
                f[j] = 0
                j += i + i
        i += 2
    return f[2:]


if __name__ == "__main__":
    ps = primes(100)
    for n in sys.stdin:
        i = int(n)
        print(i,sum(ps[:i-1]))

Python: import sys

primes = [1] * 500000
primes[0] = 0

for i in range(3, 1000, 2):
    if primes[i // 2]:
        primes[(i * i) // 2::i] = [0] * len(primes[(i * i) // 2::i])

for i in sys.stdin:
    n = int(i)
    if n < 4:
        print(n - 1)
    else:
        print(sum(primes[:(n + 1) // 2]) + 1)

Python: import sys
x = 1000000
xx = 500000
f = [1, 0] * xx
f[0] = 0
f[1] = 1
i = 3
while i < x:
    if f[i] == 1:
        j = i
        y = x // i + 1
        while j < y:
            f[j] = 0
            j += i + i
    i += 2

for n in sys.stdin:
    i = int(n)
    if i < 2:
        print(0)
    else:
        print(sum(f[:i]))

Python: import sys
lines = sys.stdin.readlines()
for line in lines:
    a = int(line)
    b = [False, False]
    for i in range(a-1):
        b.append(True)
    for i in range(a):
        if(b[i]):
            k = i
            while(k <= a-i):
                k += i
                b[k] = False
    cnt = 0
    for i in b:
        if(i):
            cnt += 1
    print(cnt)

Python: import sys
for i in sys.stdin:
    n = int(i)
    arr = [i for i in range(0,n+1)]
    for i in range(2, len(arr)):
        if arr[i] != 0:
            j = 2
            while i*j <= n:
                if arr[i*j] != 0:
                    arr[i*j] = 0
                j += 1
    primNum = 0
    for i in arr:   
        if i > 1:
            primNum += 1
    print(primNum)

Python: while True:
    try:
        n = int(input())
    except:
        break
    p_table = list(range(2,n+1))
    p = 2
    i = 0
    while i < len(p_table):
        p = p_table[i]
        j = p + p
        while j <= n:
            if j in p_table:
                p_table.remove(j)
            j += p
        i += 1
    print(len(p_table))

Python: import math
def lb(a,x):
    l=0
    r=len(a)-1
    while l<r:
        mid=int((l+r)/2)
        #print "l=",l,' r=',r
        if a[mid]<x:
            l=mid+1
        else:
            r=mid
    return l

maxn=1000001
a=[False for i in xrange(maxn)]
for i in xrange(2,int(math.sqrt(maxn))):
    for j in xrange(i+i,maxn,i):
        a[j]=True
b=[]
for i in xrange(2,maxn):
    if not a[i]:
        b.append(i)
while True:
    try:
        n=input()
        f=lb(b,n)
        if b[f]==n:
            print(f+1)
        else:
            print(f)
    except EOFError: break

Python: for i in range(30):
	try:
            n = input()
            prime_list = [2]
            i = 3;
            while i<=n :
                judge = True
                for num in prime_list :
                    if(i%num==0) :
                        judge = False
                        break
                if(judge):
                    prime_list.append(i)
                i += 2
            print(len(prime_list))
	except :
		break

Python: from sys import stdin

def prime(n: int) -> int:
    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
    print(Prime)
    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


def isp(n):
    a = 1
    for i in range(2, (n + 1) // 2 + 2):
        if not n % i:
            a = 0
            break
    return a


for i in sys.stdin:
    i = int(i)
    if i == 2:
        print(1)
    elif i == 3:
        print(2)
    else:
        s = 2
        for x in range(2, i + 1):
            if isp(x):
                s += 1
        print(s)