Go: package main

import (
    "fmt"
    "bufio"
    "os"
    "strconv"
)

func main() {
    var limit = 1000000
    var root = 1000
    var isPrime [1000000]bool
    for i := 0; i < limit; i++ {
        isPrime[i] = true
    }
    isPrime[0] = false
    isPrime[1] = false
    for i := 2; i <= root; i++ {
        if isPrime[i] {
            for j := i * i;j < limit; j+=i {
                isPrime[j] = false
            }
        }
    }
    var primeCnt [1000000]int
    var cnt = 0
    for i := 0; i < limit; i++ {
        if isPrime[i] {
            cnt++
        }
        primeCnt[i] = cnt
    }

    var sc = bufio.NewScanner(os.Stdin)
    for sc.Scan() {
        n, _ := strconv.Atoi(sc.Text())
        fmt.Println(primeCnt[n])
    }
}

Python: kazu=[]
Max=1000000
def era(kazu,Max):
    sosu=list(range(2,Max))
    while True:
        num=sosu[0]
        if num>=Max**0.5:
            kazu+=sosu
            return kazu
        kazu.append(num)
        sosu=[i for i in sosu if i%num!=0]
era(kazu,Max)
while True:
    try:
        n=int(input())
        if n==1:
            print(0)
        elif n==2:
            print(1)
        elif n>=max(kazu):
            print(len(kazu))
        else:
            for i in range(n+1):
                if kazu[i]==n:
                    print(i+1)
                    break
                elif kazu[i]>n:
                    print(i)
                    break
    except EOFError:
        break

Python: # 準備
num_list = [0] * 1000000
i = 2
cnt = 0
for num in range(2,len(num_list)):
    if num_list[i] == -1:
        num_list[i] = num_list[i-1]
        i += 1
        continue
    cnt+=1
    num_list[i] = cnt
    # num_list[i*2::i] = -1
    for j in range(i*2,len(num_list),i):
        num_list[j] = -1
    i += 1

while True:
    try:
        n = int(input())
    except Exception as e:
        break
    print(int(num_list[n]))

Python: import math
import sys

def get_primes(n):
    search = list(range(2, n+1))
    primes = []
    while True:
        primes.append(search[0])
        for i,x in enumerate(search):
            if x % primes[-1] == 0:
                del search[i]
        if len(search) == 0:
            return primes
        if search[0] >= math.sqrt(n):
            primes.extend(search)
            return primes

for line in sys.stdin.readlines():
    n = int(line)
    if n < 2:
        print(0)
    else:
        print(len(get_primes(n)))

Python: # returns the number of prime numbers less than or equal to n
def sieve(n):
    prime = [True] * (n+1)
    prime[0] = prime[1] = False
    count = 0
    for i in range(2, n+1):
        if prime[i]:
            count += 1
            for j in range(2*i, n+1, i):
                prime[j] = False
    return count


while True:
    try:
        n = int(input())
        print(sieve(n))
    except:
        break

Python: # ?´???°?????°?????¨?????????????????°??????

import sys
import math

prim_no = {2: True}                    # ????????°????´???°??§??????????????????????????????

def is_prime(no):
    if no == 2:
        return True
    
    if no % 2 == 0:
        return False

    if prim_no.get(no) is not None:
        return prim_no.get(no)

    max_check = int(math.sqrt(no))
    for i in range(3, max_check+1, 2):
        if no % i == 0:
            prim_no[no] = False
            return False

    prim_no[no] = True
    return True

def main():
    while True:
        num = sys.stdin.readline()
        if num is None or num.strip() == '':
            break

        num = int(num.strip())
        if num == 1:
            cnt = 0
        else:
            cnt = 0
            for i in range(3, num + 1, 2):
                if is_prime(i):
                    cnt += 1
            cnt += 1

        print(cnt)

if __name__ == '__main__':
    main()
    #print(prim_no)

Python: def prime(n, p):
  cnt = 0
  for i in range(n+1):
    if(p[i]):
      cnt += 1
  return cnt
  
p = [True for i in range(1000001)]
p[0] = False
p[1] = False
for i in range(2, 500001):
  for j in range(2, 1000000//i + 1):
    p[i * j] = False

while True:
  try:
    n = int(input())
  except EOFError:
    break
  print(prime(n, p))

Python: #coding:utf-8
import time
import math
import numpy as np

def flatten(L):
    if isinstance(L, list):
        if L == []:
            return []
        else:
            return flatten(L[0]) + flatten(L[1:])
    else:
        return [L]

def Eratos(data):

    p_list = [] # ????????????
    tmp = []
    num = int(math.sqrt(len(data)))+1
    for i in data:
        i=data[0]
        if i>num:
            break
        else:
            p_list.append(i)
            for j in data:
                if j%i == 0:
                    data.remove(j)
        
    p_list.append(data)
    return p_list

x = int(input())

r_list = list(range(2,(x+1)))
ans = []
ans = Eratos(r_list)

print(len(flatten(ans)))

Python: import sys
a=[0,0]+[1]*10**6
for i in range(999):
 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: def prime_count(N):
    primes = [2, 3]
    count = 1
    for n in range(5, N+1, 2):
        isprime = True
        for i in range(1, len(primes)):
            if primes[i] ** 2 > n:
                break
            if n % primes[i] == 0:
                isprime = False
                break
        if isprime:
            count += 1
    return count

while True:
    try:
        print(prime_count(int(input())))
    except:
        break

Python: import sys
from math import sqrt

for line in sys.stdin:
    n = int(line.strip())
    L, pn, tmp = int(sqrt(n)), [], [i for i in range(2, n+1)]
    while tmp[0] < L+1:
        v = tmp.pop(0)
        pn.append(v)
        tmp = list(filter(lambda x: x%v!=0, tmp))
    for t in tmp: pn.append(t)
    print(len(pn))

Python: def main():
	import sys

	MAX = 1000000

	table = [True]*1000000
	table[0] = table[1] = False

	primes = []
	counted = 0

	for i in range(MAX):
		if table[i]:
			primes.append(i)
			for j in range(2*i, MAX, i):
				table[j] = False

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

		cnt = 0
		for prime in primes:
			if prime > n:
				break
			else:
				cnt += 1
		print(cnt)


if __name__ == '__main__':
	main()

Python: def sieve(n=10**6):
  p=[1]*(n+1)
  for i in range(2,n+1):
    if p[i]:
      for j in range(2*i,n+1,i):p[j]=0
  p[0],p[1]=0,0
  return p
while True:
  try:print(sum(sieve(int(input()))))
  except:break

Python: import math
import sys

def E(d):

    p_list = [] 
    p=0
    tmp = []
    l = len(d)
    num = int(math.sqrt(len(d)))+1
    for i in d:
        i=d[0]
        if i>num:
            break
        else:
            # p_list.append(i)
            p=p+1
            for j in d:
                if j%i == 0:
                    d.remove(j)
                    l = l-1
        
    # print(len(p_list)+len(d))
    print(p+l)

for line in sys.stdin:
    x= [i for i in range(2,(int(line)+1))]
    E(x)

Python: import sys


xx = 500000
f = [0, 1] * xx

i = 3
while i * i <= 2 * xx:
    if f[i] == 1:
        j = i * i
        while j <= 2 * xx:
            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]))