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: #!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import math

N = 1000000

TABLE = [True] * N

def sieve():
    TABLE[1] = False

    sqrtn = int(math.sqrt(N))

    for i in range(2, sqrtn+1):
        if TABLE[i]:
            for j in range(2*i, N, i):
                TABLE[j] = False

    """
    for i in range(4, N, 2):
        TABLE[i] = False

    for i in range(6, N, 3):
        TABLE[i] = False

    for i in range(6, N, 6):
        p1 = 6*i - 1
        p2 = 6*i + 1

        if p1 >= N: break

        if TABLE[p1]:
            for j in range(2*p1, N, p1):
                TABLE[j] = False

        if p2 >= N: break

        if TABLE[p2]:
            for j in range(2*p2, N, p2):
                TABLE[j] = False
    """

def main():
    sieve()

    for line in sys.stdin:
        n = int(line)

        cnt = sum(map(lambda k: TABLE[k], range(1, n+1)))
        print(cnt)

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
    return sum(l)
for n in stdin:
    n = int(n)
    print(cntPrime(n))

Python: # -*- coding: utf-8 -*-

while True:
    try:
        n = int(raw_input())
        list1 = range(2, n)
        list2 = []
        while True:
            i = list1.pop(0)
            list2.append(i)
            for x in list1:
                if x % i == 0:
                    list1.remove(x)
            if i**2 > list1[::-1][0]:
                break

        print(len(list2 + list1))
    except EOFError:
        break

Python: from math import sqrt
I_list=[]
#input syutoku
while True:
	try:
		k=int(input())
		I_list.append(k)
	except:
		break

I_max=max(I_list)
#create list (I_max=100 -> [3,5,7,...,99])
odd_list=[x for x in range(3,I_max+1,2)]
#print(W_list)

P_list=[2]

p=0
#print(I_list)
ct=0
while p<=int(sqrt(I_max)):
	p=odd_list.pop(0)
	P_list.append(p)
	P_baisuu=[p*x for x in range(1, int(I_max/p) +1 )]
	K_list=set(odd_list)-set(P_baisuu)
	odd_list=sorted(list(K_list))
#	print("P_list=")
#	print(P_list)
#	print("odd_list=")
#	print(odd_list)

prime_list=P_list+odd_list
#print("prime_list=")
#print(prime_list)

for i in I_list:
	w=[j for j in prime_list if j<=i ]
	print(len(w))

Python: # coding: utf-8

import sys
import math


if __name__ == '__main__':
	input_list = sys.stdin.readlines()

	for num in input_list:
		target_number = int(num.replace('\n', ''))
		serial_number_list = [r for r in range(2, target_number + 1)]
		multiple_list = []

		while math.sqrt(target_number) >= serial_number_list[0]:
			serial_number = serial_number_list[0]
			i = 1
			multiple_list.append(serial_number)

			while target_number >= serial_number * i:
				
				if serial_number * i in serial_number_list:
					serial_number_list.pop(serial_number_list.index(serial_number * i))

				i += 1

		print(multiple_list)

Python: from math import sqrt
def eratosthenes(n):
  def era(x,p):
    if x<=p or (x>p and x%p!=0):
      return x
    else:
      return None
  A=[i for i in range(2,n+1)]
  p=2
  while p<=sqrt(n):
    A=list(filter(lambda x:era(x,p),A))
    p+=1
  return(A)
print(eratosthenes(int(input())))

Python: import math

def Eratos(n):
	primes = [2]
	if n % 2 == 0:
		num = [2*i+1 for i in range(1,n/2)]
	else:
		num = [2*i+1 for i in range(1,(n+1)/2)]
	tmp = []

	top = 1
	while top < math.sqrt(n):
		top = num[0]
		for i in range(1,len(num)):
			if num[i] % top != 0:
				tmp.append(num[i])
		num = tmp
		tmp = []
		primes.append(top)
	for i in range(len(num)):
		primes.append(num[i])
	return primes

def list_count(list_a,n):
	cont = 0
	for i in range(len(list_a)):
		if list_a[i] > n:
			break
		else:
			cont += 1
	return cont

primes = Eratos(1000000)
while True:
	try:
		n = int(input())
		print(list_count(primes,n))
	except EOFError:
		break

Python: import math
def prime(n):
    plist = [1 for i in range(n)]
    pivot = int(math.sqrt(n))
    plist[0] = 0
    if n <= 1:
        return 0
    if n == 2:
        return 1
    if n == 3:
        return 2
    else:
        for i in range(2,pivot+1):
            if plist[i-1] == 0:
                continue
            else:
                for j in range(2*i,n+1,i):
                    plist[j-1] = 0
    psum = sum(plist)
    return psum

import sys
while True:
    line = sys.stdin.readline()
    if not line: break
    n = int(line.rstrip('\r\n'))
    print(prime(n))

Python: def checkPrime(number):
    if number == 2:
        return True
    if number % 2 == 0:
        return False

    i = 3
    while (i ** 2 < number + 1):
        if number % i == 0:
            return False
        i += 2

    return True

p = [True for i in range(0, 1000000)]

p[0] = 0
p[1] = 0
for i in range(2, len(p)):
    p[i] = p[i - 1]
    if checkPrime(i):
        p[i] += 1

while True:
    try:
        print(p[int(input())])
    except:
        break

Python: while True:
    ss=input()
    if len(ss)==0:
        break
    s=int(ss)+1
    if s<2:
        print(0)
    else:
        list=[True]*s
        list[0]=False
        list[1]=False
        i=2
        while i**2<=s-1:
            j=i*2
            while j<=s-1:
                list[j]=False
                j+=i
            i+=1
        print(list.count(True))

Python: import math
while True:
    try:
        n=int(input())
        num=list(range(n+1))
        num[1]=0
        for i in range(n):
            if num[i]>pow(n,0.5):
                break
            if num[i]==0:
                continue
            for j in range(num[i]*2, n+1, num[i]):
                num[j]=0
        print(n+1-num.count(0))
    except:
        break

Python: import numpy as np
while 1:
	num = int(input())
	n = [] #素数をかくのするためのリスト
	li = [] #2から入力された値までのすべての数を格納するリスト
	
	#2から入力された値までのすべての数を格納
	li = [i for i in range(2,num+1)]
	
	#liリストの0番目が入力された値の平方根以下になるまでloop
	while li[0] <= int(np.sqrt(num)):
		n.append(li[0]) #nリストにliリストの0番目を追加
		sss = li[0] #sssにliリストの0番目を格納
		li = [i for i in li if i % sss != 0] #素数判定
	n.extend(li) #liリストに残った数を素数としてnリストに格納
	print(len(n))

Python: # coding: utf-8

import sys
import math


if __name__ == '__main__':
	input_list = sys.stdin.readlines()

	for num in input_list:
		target_number = int(num.replace('\n', ''))
		serial_number_list = [r for r in range(2, target_number + 1)]
		multiple_list = []

		while math.sqrt(target_number) >= serial_number_list[0]:
			serial_number = serial_number_list[0]
			i = 1
			multiple_list.append(serial_number)

			while target_number >= serial_number * i:
				
				if serial_number * i in serial_number_list:
					serial_number_list.pop(serial_number_list.index(serial_number * i))

				i += 1

		print(multiple_list + serial_number_list)

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)


n = int(input())
print(prime(n))