Go: package main

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

func main() {
	b2i := func(b bool) int {
		if b {
			return 1
		}
		return 0
	}

	prime := func(n int) []int {
		ans := make([]int, n+1)
		for i := 2; i <= n; i++ {
			b := ans[i] == 0
			ans[i] = ans[i-1] + b2i(b)
			if b {
				for j := i * 2; j <= n; j += i {
					ans[j] = 1
				}
			}
		}
		return ans
	}
	reader := bufio.NewScanner(os.Stdin)
	primeT:=prime(999999)
	for reader.Scan() {
		n, _ := strconv.Atoi(reader.Text())
		fmt.Println(primeT[n])
	}
}

Python: while True:
  a=int(input())
  X=[i for i in range(2,a+1)]
  Y=[]
  while True:
    X=[i for i in X if i % X[0] !=0 ]
    if X == Y:
      break
    Y=X[:]
  
  print(len(X))

Python: b=[]
b.append(1)
b.append(2)
count=1
s=0
while s<30:
    try:
        x=int(input())
        if x>b[count]:
            for i in range(b[count]+1,x+1):
                count1=0
                for j in range(2,i):
                    if i%j==0:
                        count1=1
                        break
                if count1==0:
                    count+=1
                    b.append(i)
            print(count)
        else:
            for i in range(count+1):
                if b[i]>x:
                    print(i-1)
                    break
                elif b[i]==x:
                    print(i)
                    break
        s+=1
    except EOFError:
        break

Python: import sys

primes = [1] * 500000
primes[0] = 0

for i in range(3, 1000, 2):
    if primes[i // 2]:
        primes[(i * i) // 2::i] = [0] * len(primes[(i * i) // 2::i])

for i in sys.stdin:
    n = int(i)
    if n < 4:
        print(n - 1)
    else:
        print(sum(primes[:(n + 1) // 2]) + 1)

Python: is_prime = [i for i in range(1000000)]

is_prime[0] = is_prime[1] = False

for i in range(2,1000000):
    is_prime[i] = True

for i in range(2,1000000):
    if i*i >= 1000000:
        break
    if is_prime[i]:
        for j in range(i*i,1000000,i):
            is_prime[j] = False

n_prime = [i for i in range(1000000)]

def main():
    cnt = 0
    for i in range(1000000):
        if is_prime[i]:
            cnt += 1
        n_prime[i] = cnt

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

if __name__ == "__main__":
    main()

Python: import sys
[print(sum([1 if sum([0 if y % z != 0 else 1 for z in range(2, y)]) == 0 else 0 for y in [y + 1 for y in range(2, x)]]) + 1) for x in [int(x) for x in sys.stdin]]

Python: lis=[True for i in range(int(1e6+1))]

lis[0]=lis[1]=False
end=int(1e6**0.5)
for i in range(end+1):
    if lis[i]:
        for j in range(i*2,int(1e6+1),i):
            lis[j]=False

while True:
    try:
        n=int(input())
        cnt=0
        for i in range(n+1):
            if lis[i]:cnt+=1
        print(cnt)
        
        
    except EOFError:
        break

Python: import sys
def main():
    for line in sys.stdin:
        n = int(line)
        hoge = [i for i in range(2, n + 1) if i % 2 != 0 or i == 2]
        fuga = [2]
        for i in range(1, len(hoge)):
            cnt = 0
            for j in range(i):
                if hoge[i] % hoge[j] != 0:
                    cnt += 1
            if cnt == i:
                fuga.append(hoge[i])
        print(len(fuga))


if __name__ == "__main__":
    main()

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("prime numbers is ")

print(len(flatten(ans)))

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 or len([j for j in primes if i % j == 0]) > 0:
          continue
        primes.append(i)
    ans = [i for i in primes if i <= n]
    print(len(ans))
  except:
    break

Python: import math
import sys

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

nums = [1] * (n+1)
nums[:2] = [0,0]
    
cnt = 0
while cnt <= math.sqrt(n):
    flg = nums[cnt]
    if flg == 1:
        k = 2
        while k*cnt <= n:
            nums[k*cnt] = 0
            k += 1
    cnt += 1
sum(nums)

Python: import sys
for line in sys.stdin:
    n = int(line)
    flag = [True]*(n+1)
    flag[0] = flag[1] = False
    for i in range(2,int(n**0.5)+1):
        if flag[i]:
            for j in range(i**2, n+1, i):
                flag[j] = False
    print(flag.count(True))

Python: max_num = 1000000
cnt = 0
p = [1] * max_num
p[0] = p[1] = 0
for i in xrange(2, int(max_num ** 0.5) + 1):
    if p[i]:
        p[i * i::i] = [0] * len(p[i * i::i])

for i in xrange(max_num):
    cnt += p[i]
    p[i] = cnt

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

Python: from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

def enum_prime(n):
    if n < 2:
        return []
    if n == 2:
        return [2]
    L = list(range(2, n + 1))
    PL = []
    while True:
        PL.append(L[0])
        L = [i for i in L if i % PL[-1] != 0]
        if L[-1] < PL[-1] ** 2:
            return PL + L

primelist = enum_prime(999999)
for line in stdin:
    n = int(line)
    cnt = 0
    for p in primelist:
        if n < p:
            break
        cnt += 1
    print(cnt)

Python: LIMIT = 10000000
 
isPrime = [True for _ in range(LIMIT)]

isPrime[0] = isPrime[1] = False
 
for i in range(2, int(LIMIT ** 0.5)+1):
  if isPrime[i]:
    for j in range(i * i, LIMIT, i):
      isPrime[j] = False
 
try:
    while True:
        n = int(input())

        count = 0
        if n >= 2:
            count = 1

        for i in range(3, n+1, 2):
            if isPrime[i]:
                count += 1

        print(count)
except EOFError:
  pass

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)+1)))

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

Python: import sys


def prime(x):
    for i in p_list:
        if x % i == 0:
            return 0
    return 1


if __name__ == "__main__":
    a = 10000
    i = 2
    p_list = []
    while i < a:
        if prime(i):
            p_list.append(i)
        i += 1
    print(p_list)

    for i in sys.stdin:
        n = int(i)
        while 1:
            if n not in p_list:
                n -= 1
            else:
                print(p_list.index(n) + 1)

Python: import sys
#from me.io import dup_file_stdin

N=1000000
primes = [1]*N
primes[0:2]=[0,0,1]

for i in range(2,N):
    if primes[i]==1:
        j=i+i
        while j<=N:
            primes[j]=0
            j+=i

#@dup_file_stdin
def solve():
    for query in map(int,sys.stdin):
        print(sum(primes[2:query+1]))
solve()