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] = i
        }

        Soe()

        for i := 0; i < MAX; i++ {
                primes[i] %= 2
        }
        primes[1] = 0
        primes[2] = 1
}

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

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)

Python: # PrimeNumber
# エラトステネスの篩

from itertools import product
import math

if __name__ == "__main__":
    while True:
        try:
            # 数値の入力があった
            n = int(input())
            nlist = []
            nlist2 = []
            plist = []

            # for i in range(2, n + 1):
            #    nlist.append(i)  # [2,3,4,5,6,...,n]
            nlist = range(3, n + 1, 2)

            while True:
                #print(nlist, " ", math.sqrt(n))
                sqrtn = math.sqrt(n)
                if nlist[0] > sqrtn:  # 終了条件
                    #plist.append(map(int,nlist))
                    plist.extend(nlist)
                    break
                else:
                    plist.append(nlist[0])

                    #i = 0
                    for j in nlist:
                        if j % nlist[0] != 0:
                            #nlist.pop(i)
                            #nlist.remove(j)
                            nlist2.append(j)
                            #i += 1
                    nlist = nlist2
                    nlist2 = []
            #print("fin: {}".format(plist))
            print(len(plist)+1) # 2の分を追加

        except EOFError:
            break  # escape from while loop

pass
#

Python: from math import sqrt
from sys import stdin

def isprime(x) :
    i = 3
    while i <= int(sqrt(x)) + 1 :
        if x % i == 0 : return False
        i = i + 2
    return x

for Input in stdin :
    if int(Input) == 1 : print(0)
    elif int(Input) == 2 : print(1)
    else:
        result = 1
        for make in range(3, int(Input) + 1, 2) :
            if isprime(make) != False : result += 1
        print(result)