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 sys
def prime_calc(n):
    if n < 2:
        return 0
    else:
        i = 2
        while i*i <= n:
            if n % i == 0:
                return 0
            else:
                i = i + 1

    return 1

def prime(n):
    cnt = 0
    for i in range(1, n+1):
        ans = prime_calc(i)
        if ans == 1:
           cnt = cnt + 1

    return cnt

def no_debug_input(array):
    for line in sys.stdin:
        array.append(int(line))

def debug_input(array):
    parser = argparse.ArgumentParser()
    parser.add_argument("filename", help="The filename to be processed")
    args = parser.parse_args()

    if args.filename:
        with open(args.filename) as f:
            for line in f:
                a = int(line.rstrip())
                array.append(a)

def main():
    l = []

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

    for line in l:
        print(prime(line))

if __name__ == "__main__":
    main()

Python: from math import sqrt
cash = {}
def isprime(n):
    if n in cash:
        return cash[n]
    if n == 1:
        cash[n] = 0
        return 0
    if n == 2:
        cash[n] = 1
        return 1
    if n % 2 == 0:
        cash[n] = 0
        return 0
    for i in range(3,int(sqrt(n)+1))[0::2]:
        if n % i == 0:
            cash[n] = 0
            return 0
    cash[n] = 1
    return 1

from sys import stdin
cash2 = {}
for i in stdin:
    i = int(i)
    c = sum(isprime(n) for n in range(2,i+1))
    print(c)

Python: def Eratosthenes(n):
	N = [1 for i in range(0,n+1)]
	i = 3
	while i*i<=n:
		if N[i]:
			j = i*i
			while j<=n:
				N[j] = 0
				j += i*2
		i += 2
	return N

N = Eratosthenes(999999)
while True:
	try:
		n = int(input())
	except EOFError:
		break
	cnt = 0
	if n>=2:
		cnt = 1
	for i in range(3, n+1, 2):
		cnt += N[i]
	print(cnt)

Python: import math as m

while(True):
    try:
        n = input()
    except EOFError:
        break
    
    an = 0
    n = int(n)
    

    an = n
    a = [True for i in range(n+1)]
    
    j=2
    while True:
        if j > m.sqrt(n):
            break
        
        if a[j]==False:
            j = j+1
            continue
        
        k=2
        while k*j <= n:
            if a[k*j]==True:
                #print(k*j)
                a[k*j]=False
                an = an-1
            
            k=k+1
        
        j=j+1

    if n==2:
        an = 2

    if n==3:
        an = 3

    print(an-1)

Python: p = [0, 0, 1, 1, 0, 1]
while True:
    try:
        n = int(input())
        if len(p) < n+1:
            i = len(p)
            while i < n+1:
                j = 2
                flag = True
                while j <= i**0.5:
                    if i % j == 0:
                        p.append(0)
                        flag = False
                        break
                    j += 1
                if flag == True:
                    p.append(1)
                i += 1
        print(sum(p[0:n+1]))
    except:
        break

Python: import bisect
num = 1000000
L = [True] * (num+1)
L[0] = False
L[1] = False
for i in range( 2, int(num**0.5)+ 2 ):
    if not L[i]:
        continue
    for j in range(i*2, num+1, i):
        L[j] = False

p = [ x for x in range(num+1) if L[x] ]

while True:
    try:
        n = int(input())
        k = bisect.bisect_left(p,n+1)
        print(k)
    except:
        break

Python: from math import *

search_list = []
prime_list = []
target = 0

def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break
if __name__ == '__main__':
    array = list(get_input())
    for i in range(len(array)):
        #??\????????¨?????????????????????????????§?´???°????????°?????¢?´¢??????
        for j in range(2,int(array[i])+1):
            #??¢?´¢??????????????????
            search_list.append(j)
        #print(sqrt(int(array[i])))
        while True:
            if target > sqrt(int(array[i])):
                prime_list = prime_list + search_list
                break
            prime_list.append(search_list[0])
            target = search_list[0]
            search_list.pop(0)
            k = 1
            while target*k<=search_list[-1]:
                #print(target * k)
                if target*k in search_list:
                    search_list.remove(target*k)
                k += 1
            #print(search_list)
        #print(str(array[i]) + "??\???????´???°???" + str(prime_list) + "??????????????°???" + str(len(prime_list)))
        print(len(prime_list))
        target = 0
        prime_list.clear()
        search_list.clear()

Python: import sys
import math

N = []
ns = sys.stdin.readlines()
for n in ns:
    N.append(int(n))
ml = max(N)
P = [2]
for x in range(3, ml+1):
    flag = True
    for d in [p for p in P if (p < int(math.sqrt(x))+1)]:
        flag = flag and (x % d != 0)
    if flag == True:
        P = P + [x]
for m in N:
    print(len([p for p in P if p<=m]))

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

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

Python: if __name__ == '__main__':
    while True:
        n = int(input())
        is_prime = [True for i in range(n + 1)]
        is_prime[0] = False
        is_prime[1] = False

        p = 0

        for i in range(2, n + 1):
            if is_prime[i]:
                p += 1
                for j in range(i * 2, n + 1, i):
                    is_prime[j] = False

        print(p)

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

inputs = sys.stdin.readlines()
for s in inputs:
    n = int(s)
    lst = Eratosthenes(n)
    print(len(lst))

Python: import sys

rand = random.randint

def prime(n):
	if n == 2: return True
	if n < 2 or n & 1 == 0: return False
	return pow(2, n-1, n) == 1

a = [prime(i) for i in range(1000000)]

for s in sys.stdin:
	i = int(s)
	print(a[:i+1].count(True))

Python: import math as m
while True:
	try:
		n=int(input())
		a=[0]*(n+1)
		a[0],a[1]=1,1
		for i in range(2,int(m.sqrt(n))+1):
			for j in range(2,int(n/i)+1):
				a[i*j]=1
		print(a.count(0))
	except:
		break

Python: import sys
from itertools import takewhile
primes = [2, 3, 5, 7]
append_prime = primes.append
upper = 10


def is_prime(num):
    for p in primes:
        if num % p == 0:
            return False
    return True


def calc_prime(num):
    for i in range(upper + 1, num + 1):
        if is_prime(i):
            append_prime(i)

for s in sys.stdin:
    n = int(s)
    if upper < n:
        calc_prime(n)
        upper = n
        print(len(primes))
    else:
        print(len(tuple(takewhile(lambda x: x <= n, primes))))