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


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
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):
        
        if serial >= sqrt:
            # print([i for i, b in enumerate(input_list) if b == True])
            return sum(input_list)

        for s in range(serial ** 2, num, serial): 
            input_list[s] = False


if __name__ == '__main__':
    while True:
        try:
            n = int(input())
        except:
            break

        print(sieve_of_erastosthenes(n))

Python: import sys
 
 
f = [0, 1] * 500000
 
i = 3
while i <= 1000:
    if f[i] == 1:
        j = i * i
        while j <= 1000000:
            f[j] = 0
            j += i + i
    i += 2
 
f.pop(0)
f.pop(1)
 
for n in sys.stdin:
    i = int(n)
    if i < 2:
        print(0)
    else:
        print(sum(f[:i - 1]))

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])
for e in map(int,sys.stdin):print([e-1,sum(a[:(e+1)//2])][e>3])

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