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: M = 10**6

p = [0]*(M+60)
sM = M**0.5
for x in range(1, int(sM/2)+1):
    v = 4*x*x + 1; y = 8
    while v <= M:
        if v % 12 != 9: # v % 12 in [1, 5]
            p[v] ^= 1
        v += y; y += 8
for x in range(1, int(sM/3**0.5)+1, 2):
    v = 3*x*x + 4; y = 12
    while v <= M:
        if v % 12 == 7:
            p[v] ^= 1
        v += y; y += 8
for x in range(2, int(sM/2**0.5)+1):
    v = 2*x*(x+1)-1; y = 4*x-8
    while 0 <= y and v <= M:
        if v % 12 == 11:
            p[v] ^= 1
        v += y; y -= 8

for n in range(5, int(sM)+1):
    if p[n]:
        for z in range(n*n, M, n*n):
            p[z] = 0
p[2] = p[3] = 1

c = [0]*M
cnt = 0
for i in range(M):
    if p[i]:
        cnt += 1
    c[i] = cnt

while 1:
    try:
        n = int(input())
    except:
        break
    print(c[n])

Python: import math as m
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))

Python: import sys

def prime_calc(n):
    if n < 2:
        return False
    else:
        i = 2
        while n > i:
            if n % i == 0:
                return False
            else:
                i += 1
    return True

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

    return cnt

def main():
    l = []
    
    for line in sys.stdin:
        l.append(int(line))

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

if __name__ == "__main__":
    main()

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(len(multiple_list + serial_number_list))

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: l = [1 for i in range(10 ** 6 + 1)]
l[0] = l[1] = 0
for i in range(10 ** 6 + 1):
  if l[i] == 1:
    for j in range(i * 2, 10 ** 6 + 1, i):
      l[j] = 0
while 0 == 0:
  try:
    n = int(input())
    c = 0
    for i in range(n + 1):
      c += l[i]
    print(c)
  except EOFError:
    break

Python: import math
import sys

a = [1]*10000000
a[0] = a[1] = 0

for i in range(2,int(math.sqrt(2000000))):
    if a[i] == 1:
        for j in range(i+i,2000000,i):
            a[j] = 0

for i in range(1,2000000):
    a[i] += a[i-1]
    
for line in sys.stdin:
    print(a[int(line)])

Python: import sys
import math as mas

def sieve(n):
	p=[True for i in range(n+1)]
	p[0]=p[1]=False
	end=int(n**0.5)
	for i in range(2,end+1):
		if p[i]:
			for j in range(i*i,n+1,i):
				p[j]=False
	return p
	
sosu=sieve(1000010)
for i in sys.stdin:
	print(sum(sosu[t] for t in range(int(i))))

#	a,b=map(int,i.split())
#	print(gcd(a,b),lcm(a,b))

Python: # the sieve of Eratosthenes
primes = [1] * 1000000
primes[0] = 0
primes[1] = 0
for i in range(2, 1000):
    if primes[i]:
        primes[i*2::i] = [0] * len(primes[i*2::i])

from itertools import accumulate
acc_primes = list(accumulate(primes))

for i in range(30):
    try:
        n = int(input())
        print(acc_primes[n])
    except EOFError:
        break

Python: import sys

MAX = 999999

def is_prime(n):
  if n == 2:return True
  if n % 2 == 0:return False
  for i in range(3,int(n**0.5)+1,2):
    if n % i == 0:return False
  return True

def prime_list(n):
  result = []
  if n >= 2:result.append(2)
  for i in range(3,n+1,2):
    if is_prime(i):result.append(i)
  return result

L = prime_list(int(MAX**0.5))

def is_prime_2(n):
  a = int(n ** 0.5)
  for i in L:
    if i > a:return True
    if n % i == 0:return False
  return True

def prime_count(n):
  result = 0
  if n >= 2:result+=1
  for i in range(3,n+1,2):
    if is_prime_2(i):result+=1
  return result

L2 = prime_list(MAX)

def prime_count_2(n):
  for i,v in enumerate(L2):
    if v > n:return i
  return len(L2)

for n in sys.stdin:
  print(prime_count_2(int(n)))

Python: import math
n = 1000001
rn = round(math.sqrt(n)) + 1
tbl = [True for i in range(n)]
tbl[0], tbl[1] = False,False
for i in range(4,n,2):
    tbl[i] = False
for i in range(3,rn,2):
    if tbl[i]:
        for j in range(i*2,n,i):
            tbl[j] = False
n = int(input())
while 1:
    print(sum(tbl[:n+1]))
    try: n = int(input())
    except EOFError:break