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: lst = [1]*999999
for i in range(999999):
    if i == 0:
        lst[i] = 0
    else:
        if lst[i] == 1:
            j = i +1
            k = i
            while True:
                k = k + j
                if k >= 999999:
                    break
                        
                lst[k] = 0

while True:
    try:
        n = int(input())
        anslst = lst[:n]
        print(sum(anslst))
        

    except EOFError:
        break

Python: # nまでの自然数が素数かどうかを表すリストを返す
# Sieve of Eratosthenes
def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if isPrime[i]:
            for j in range(i * i, n + 1, i):
                isPrime[j] = False
    return isPrime

ls = makePrimeChecker(10**6)

ls_ans = []
while True:
    try:
        n = int(input())
        ls_ans.append(sum(ls[:n+1]))
    except:
        break

for i in range(len(ls_ans)):
    print(ls_ans[i])

Python: while True:
    try:
        Num = 1
        n = int(input())
        for i in range(2,n+1):
            for j in range(2,i):
                if i % j == 0:
                    break
                if j == i-1:
                    Num +=1
        print(Num)           
    except EOFError:
        break

Python: import math
import sys

sup = 1000000

is_prime = [0] * sup

count = [0] * sup

def setup():
    is_prime[2] = 1
    for n in range(3,sup,2):
        flag = True
        for i in range(3, int(math.floor(math.sqrt(n) + 1)), 2):
            if n % i == 0:
                flag = False
                break
        if flag:
            is_prime[n] = 1

def precount():
    for n in range(2, sup):
        count[n] = count[n-1] + is_prime[n]

def main():
    setup()
    precount()

    l = []

    for line in sys.stdin:
        l.append(int(line))

    for line in l:
         print(count[line])

if __name__ == "__main__":
    main()

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, floor(n/c) + 1, 1):
            l[c * 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: import sys
m=10**6;a=[0,0]+[1]*m
for i in range(999):
 if a[i]:
  for j in range(i*2,m,i):a[j]=0
for e in sys.stdin:print(sum(a[:int(e)+1]))

Python: def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break
if __name__ == '__main__':
    array = list(get_input())
    cnt,flag = 0,0
    for i in range(len(array)):#?????°????????°????????????
        for j in range(2,int(array[i])+1):#1??????????´??????¢??????????´???°??¢?´¢????????????
            flag = 0
            if j == 2:
                flag = 1
            for k in range(2,j):
                if j % k == 0:
                    flag = 0
                    break
                flag = 1
            if flag == 1:
                cnt += 1  
        print(cnt)
        cnt = 0

Python: import sys

ary=[]
for i in sys.stdin:
    ary.append(int(i))

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

for m in ary:
    s = 0
    for i in range(2, m+1):
        if isp(i):
            s += 1
    print(s)

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

    # print([i for i, b in enumerate(input_list) if b == True])
    return sum(input_list)


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

        if 5 >= n:
            print(1)
        
        else:
            print(sieve_of_erastosthenes(n))

Python: l = [True] * 100000
for i in range(2, 100000):
    if (l[i - 1]):
        for j in range(i ** 2 - 1, 100000, i):
            l[j] = False

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

Python: def p(n):
    l = list(range(2,n+1))
    p = 2
    i = 0
    p = l[i]
    while True:
        pl = len(l)
        l = list(filter(lambda n: n%p != 0 or n == p,l))
        i += 1
        p = l[i]
        if pl == len(l):
            return pl

from sys import stdin
for i in stdin:
    print(p(int(i)))

Python: import sys

N = 1000
lst = [2]
for i in range(2, N)[1::2]:
    lst.append(i)
    for j in range(3, 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)
            break

Python: max_n = 999999
prime_list = [1] * (max_n + 1)

# 0, 1は素数ではない
prime_list[0:2] = [0, 0]

# 
for i in range(2, int(max_n**0.5) + 1):
    if prime_list[i] == 1:
        prime_list[i**2::i] = [0] * len(prime_list[i**2::i])

while True:
    try:
        n = int(input())
        print(sum(prime_list[:n + 1]))

    except EOFError:
        break

Python: import sys
import math
 
N = 1000000
primes = [1] * (N//2)
primes[0] = 0
 
for i in range(3,int(math.sqrt(N)),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 < 3:
        print(n-1)
    else:
        print(sum(primes[0:(n+1)//2])+1)

Python: import sys
import math
M = 1000000
B = int(math.sqrt(M)+1)
N = M//6
N1 = N+1 if M % 6 == 5 else N
N2 = N+1 if M % 6 >= 1 else N
l = [1] * N1
m = [1] * N2
for i in range(5,B,6):
    p = (i-5)//6
    ini = (i*5-1)//6
    if l[p] == 1:
        l[p+i::i] = [0] * len(l[p+i::i])
        m[ini-1::i] = [0] * len(m[ini-1::i])
    if m[p] == 1:
        m[p+i+2::i+2] = [0] * len(m[p+i+2::i+2])
        l[ini+1::i+2] = [0] * len(l[ini+1::i+2])
for i in sys.stdin:
    n = int(i)
    r =  n-1 if n < 3 else sum(l[0:(n+1)//6])+sum(m[0:(n-1)//6])+2
    print(r)

Python: import sys

def sieve(n):
    N = n + 1
    ints = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(N)]
    try:
        ints[0] = ints[1] = False
        ints[2] = ints[3] = ints[5] = True
    except IndexError:
        pass
    sqrt = N ** 0.5

    for i in range(3, N, 2):
        if i >= sqrt:
            break
        for m in range(i ** 2, N, i):
            ints[m] = False
    return ints

prime1m = sieve(1000000)

for line in sys.stdin:
    print(prime1m[:int(line) + 1].count(True))

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:
	n = int(input())
	print(len(Eratosthenes(n)))