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: 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: import sys
a=[0,0]+[1]*10**6
for i in range(999):
 if a[i]:a[i*2::i]=[0 for j in a[i*2::i]]
for e in sys.stdin:print(int(e)-len([i for i in li[:int(e)+1]if i]))

Python: import sys

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 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: import sys
a=[1]*500000
for i in range(3,999,2):
 if a[i//2]:a[(i*i)//2::i]=[0]*len(a[(i*i)//2::i])
for e in map(int,sys.stdin):print([e-1,sum(a[:(e+1)//2])][e>3])

Python: import sys

N = 1000000
lst = [1] * N
for i in range(3, int(N**0.5)+1, 2):
    if lst[i] == 1:
        lst[i*i::2*i] = [0] * len(lst[i*i::2*i])
lst = [2] + [i for i in range(3, N, 2) if lst[i] == 1]
for i in sys.stdin:
    for j in range(len(lst)):
        if lst[j] > int(i):
            print(j)
            break

Python: def prime_checker(n, option = False) -> list:
    p = [False, True, False, False, False, True] * (n // 6 + 1)
    del p[n + 1:]
    p[1 : 4] = False, True, True
    for x in range(5, int(n**.5 + 1)):
        if p[x]:
            p[x * x :: 2*x] = [False] * ((n // x - x) // 2 + 1)
    return [e for e, q in enumerate(p) if q] if option else p

from itertools import accumulate
*c, = map(int, open(0))
*p, = accumulate(prime_checker(max(c)))
for i in c:
    print(p[i])

Python: #!/usr/bin/env python
# -*- coding: utf-8 -*-


def sieve(ks):
    rejected_set = {x for x in ks for i in range(
        1, x) for j in range(i, x) if i + j + 2 * i * j == x}
    return {2} | {2 * y + 1 for y in (ks - rejected_set)}


def number_of_primes(n):
    return len({p for p in sieve(set(range(1, n + 1))) if p <= n})


def main():
    raw_args = []
    while True:
        try:
            raw_args.append(input())
        except EOFError as e:
            break
    for n in map(int, raw_args):
        print(number_of_primes(n))

if __name__ == "__main__":
    main()

Python: def isprime(x):
    if x == 2:
        return True
    elif x < 2 or x%2 == 0:
        return False
    i = 3
    while i <= pow(x,1/2):
        if x%i == 0:
            return False
        i = i + 2
    return True
import sys
import itertools as it
line = sys.stdin.readlines()
for n in line:
    n = int(n)
    if n == 2:
        print(1)
    else:
        count = 1
        for s in range(3,n+1,2):
            if isprime(s):
                count += 1
    print(count)

Python: from math import sqrt
n = 1000000
l = [1]*n
c = [0]*n
d = 0
l[1]= l[0] = 0
for i in range(4,n,2):
    l[i] = 0
for i in range(9,n,2):
    for j in range(3,int(sqrt(i))+1,2):
        if i % j == 0:
            l[i] = 0
            break
for i in range(n):
    if l[i] == 1:
        d += 1
    c[i] = d
while True:
    try:
        n = int(input())
        print(c[n])
    except:
        exit()

Python: import sys

primes = [2]
for line in sys.stdin:
  try:
    n = int(line)
    if n > max(primes):
      for i in range(max(primes) + 1, n + 1):
        if i % 2 == 0:
          continue
        primes.append(i)
        for p in primes:
          if i % p == 0 and i != p:
            primes.pop()
            break
    ans = [i for i in primes if i <= n]
    print(len(ans))
  except:
    break

Python: import math
while True:
  try:
    n = int(input())
    primes = [1] * (n+1)
    for i in range(2, int(math.sqrt(n))+1):
      if primes[i] == 1:
        for j in range(i*i, n+1, i):
          primes[j] = 0
    print(sum(primes)-2) 
  except EOFError:
    break

Python: a=[0]+[1]*10*6
for i in range(999):
 if a[i]:
  a[i*2+1::i+1]=[0 for e in range(len(li[i*2+1::i+1]))]
for e in sys.stdin:print(len([i for i in li[:int(e)]if i]))

Python: import sys
import math

N = 1000000
primes = [1] * (N//2+1)
primes[0] = 1

for i in range(3,int(math.sqrt(N))+1,2):
    if primes[i//2]:
        primes[(i*i)//2::i] = [0] * len(primes[(i*i)//2::i])
    primes[i//2] += primes[i//2-1]

for i in range(int(math.sqrt(N))+1,N+1,2):
    primes[i//2] += primes[i//2-1]


for i in sys.stdin:
    n = int(i)
    if n == 1:
        print(0)
    elif n == 2:
        print(1)
    else:
        print(primes[(n-1)//2])

Python: import sys
pr = [1]*1000000
pr[0] = 0
pr[1] = 0
for i in range(2,int(len(pr)/2)):
	if pr[i]==1:
		j = i*2
		while j < int(len(pr)/2):
			pr[j] = 0
			j += i

print(pr[:100])

for line in sys.stdin:
	n = int(line)
	cnt = 0
	for i in range(n+1):
		if pr[i]==1:
			cnt += 1
	print(cnt)

Python: def main():
    List=[]
    while True:
        try:
            IN=int(input())
            for i in range(2,IN+1):
                List.append(i)

            j=0
            while (j+1)<=len(List):
                l=len(List)
                for k in range(l-1,j,-1):
                    a=List[k]%List[j]
                    if a==0:
                        del List[k]
                    else:
                        pass

                j+=1

            print(len(List))
                    
        
        except:
            break

Python: import math
import sys

def count_primes(n):
    is_prime = [True] * n
    is_prime[0] = is_prime[1] = False
    up = math.sqrt(n)
    primes = [2]
    while True:
        nxt = None
        for i in range(primes[-1] + 1, n + 1):
            if i % primes[-1] == 0:
                is_prime[i-1] = False
            else:
                if nxt is None:
                    nxt = i
        if primes[-1] >= up:
            cnt = 1
            for b in is_prime:
                if b is True:
                    cnt +=1

                
            return cnt 

        primes.append(nxt)


print(count_primes(100))

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

Python: import sys
import math

def Prime():
    isPrime=[1 for i in range(0,1000000)]
    isPrime[0]=isPrime[1]=0
    numPrime=[0 for i in range(0,1000000)]

    for i in range(2,int(math.sqrt(1000000)+1),1):
        if isPrime[i]==1:
            numPrime[i]=numPrime[i-1]+1
            for j in range(i+i,1000000,i):
                isPrime[j]=0
        else:
            numPrime[i]=numPrime[i-1]


    for n in sys.stdin:
        print(numPrime[int(n)])
    

#testWriteFile()
Prime()

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


num = input()
if num == 2:
    print(1)
elif num == 3:
    print(2)
else:
    s = 2
    for x in range(2, num + 1):
        if isp(x):
            s += 1
    print(s)