Go: package main
import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	//"math"
)

var sc = bufio.NewScanner(os.Stdin)

func main(){
	for sc.Scan(){
		n := nextInt()
		fmt.Println(calc(n))
	}
}

func calc(n int)int{
	// エラトステネスで数え上げる
	// 最初から999999まで用意しておいて入力のたびO(1)で出すのとどっちが速いのかはわからん
	eratos := make([]bool, n+1)
	c := 0
	for i:=2; i<len(eratos); i++{
		if eratos[i] == false{
			c++
			for j:=i*i; j<len(eratos); j+=i{
				eratos[j]=true
			}
		}
	}
	return c
}

func next()string{
	return sc.Text()
}

func nextInt()int{
	a, _ := strconv.Atoi(next())
	return a
}

Python: 
import math

m=999999
s=int(math.sqrt(m)+1)
li=[0]*m
li[0]=1
for i in range(1,s):
    if li[i]==0:
        li[i*2+1::i+1]=[1 for e in range(len(li[i*2+1::i+1]))]
while True:
    try:n=int(input())
    except:break
    print(len([i for i in li[:n:] if i==0]))

Python: import sys
m=10**6;a=[0,0]+[1]*m
for i in range(2,999):
 if a[i]>0:
  for j in range(i*2,m,i):a[j]=0
for e in sys.stdin:print(sum(a[:int(e)+1]))

Python: import sys
a=[0,0,1]+[1,0]*499999
for i in range(3,999,2):
 if a[i]:a[i*i::i]=[0]*len(a[i*i::i])
for e in sys.stdin:print(sum(a[:int(e)+1]))

Python: import sys
a=[0,0,1]+[1,0]*499999
for i in range(3,999,2):
 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: import sys,random

rand = random.randint

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: # -*- coding:utf-8 -*-
import sys

# n??\???????´???°?????°?????????
def prime(n):
    l = range(0,n+1)
    i,k = 0,2
    result = 1

    if n >= 3:
        prime_nums = [2, 3]
    else:
        prime_nums = []

    while i <= n:
        while l[i] > k:
            result = l[i]%k
            k = k+1
            if result == 0:
                break
            if (l[i]-1 == k) and (result != 0):
                prime_nums.append(l[i])

        i, k = i+1, 2

    #return prime_nums
    return len(prime_nums)

while True:
    try:        
        psum = prime(int(input()))
        print(psum)
    except:
        break

Python: import sys
  
N = 1000000
primes = [1] * (N//2)
primes[0] = 0
  
for i in range(3,int(N**0.5),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 < 3:
        print(n-1)
    else:
        print(sum(primes[:(n+1)//2])+1)

Python: def mk_table(n):
    res = [1] * (n + 1)
    res[:2] = 0, 0

    for i in range(2, n):
        if i ** 2 > n:
            break

        if res[i] == 1:
            for j in range(i*2, n // i + 1, i):
                res[j] = 0

    return res


tbl = mk_table(999999)
try:
    while 1:
        print(len([x for x in tbl[:int(input())+1] if x == 1]))
except Exception:
    pass

Python: import sys
from math import sqrt, floor


def is_prime(n):
    for i in range(3, floor(sqrt(n)) + 1, 2):
        if not n % i:
            return False
    return True


def count_prime(input_list):
    count = max(input_list) > 1
    inset = sorted((n, i) for i, n in enumerate(input_list))
    i = 3
    for t in inset:
        t0 = t[0]
        while i <= t0:
            count += is_prime(i)
            i += 2
        yield (t[1], str(count))


print('\n'.join(t[1] for t in sorted(count_prime(list(map(int, sys.stdin))))))

Python: import sys
import math
M = 1000000
B = int(math.sqrt(M)+1)//6+1
N = M//6
N1 = N+1 if M % 6 == 5 else N
N2 = N+1 if M % 6 >= 1 else N
l = [1] * N1
m = [1] * N2
i = 5
ini = 4
for p in range(B):
    if l[p] == 1:
        l[p+i::i] = [0] * len(l[p+i::i])
        m[ini-1::i] = [0] * len(m[ini-1::i])
    if m[p] == 1:
        m[p+i+2::i+2] = [0] * len(m[p+i+2::i+2])
        l[ini+1::i+2] = [0] * len(l[ini+1::i+2])
    i += 6
    ini += 5

for i in sys.stdin:
    n = int(i)
    r =  n-1 if n < 3 else sum(l[0:(n+1)//6])+sum(m[0:(n-1)//6])+2
    print(r)

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 i % 3 == 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 sys

def prime(maximum):
    sieve = [True] * (maximum + 1)

    def sieved(prime):
        for not_prime in range(prime + prime, len(sieve), prime):
            sieve[not_prime] = False

    sieve[0] = sieve[1] = False
    sieved(2)
    for x in range(3, int(maximum ** 0.5) + 1, 2):
        if sieve[x]: sieved(x)
    return [prime for prime, is_prime in enumerate(sieve) if is_prime]

count = 0
numbers = []
for line in sys.stdin:
    numbers.append(int(line))
    count += 1

counts = []
for i in range(count):
    counts.append(0)

for prime in prime(1000000):
    if prime > 999999:
        break
    for i in range(count):
        if prime <= numbers[i]:
            counts[i] += 1

for count in counts:
    print(count)

Python: def solve(n):
	A=[0 for i in range(n+1)]
	A[2]=1
	for i in range(2,n+1):
		cnt=0
		for j in range(1,i+1,2):
			if i%j==0:
				cnt+=1
		if cnt==2:#1??¨????????°??????
			A[i]=1
	return sum(A) 

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

Python: LIMIT = 999999

prime = [0, 1] + [0 if i % 2 == 0 else 1 for i in range(3, LIMIT + 1)]

for i in range(3, LIMIT + 1):
    if prime[i - 1]:
        for j in range(i ** 2, len(prime), i):
            prime[j - 1] = 0

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

Python: def mk_table(n):
    res = [1] * (n + 1)
    res[:2] = [0, 0]

    for i in range(2, n):
        if i ** 2 > n:
            break

        if res[i] == 1:
            j = 2
            while i * j <= n:
                res[i * j] = 0
                j += 1

    return res


tbl = mk_table(999999)
try:
    while 1:
        print(len([x for x in tbl[:int(input())+1] if x == 1]))
except Exception:
    pass

Python: MAX = 1000000
SQRT = 1000     # sqrt(MAX)
 
prime = [0] * MAX
 
def sieve():
    for i in range(3, MAX, 2):
        prime[i] = 1
    for i in range(3, SQRT, 2):
        if prime[i] == 1:
            for j in range(i*i, MAX, i):
                prime[j] = 0
 
sieve()
cnt = [0] * (MAX+1)
cnt[2] = f = 1
for i in range(3, MAX, 2):
    if prime[i]:
        f += 1;
    cnt[i] = cnt[i+1] = f
     
while True:
    try:
        print(cnt[int(input())])
    except EOFError:
        break

Python: def is_prime(x):
    x=abs(x)
    if x==2:
        return True
    if x<2 or x&1==0:
        return False
    return pow(2,x-1,x)==1
while True:
    try:
        n=int(input())
    except:
        break
    print(sum(is_prime(i)==True for i in range(2,n+1)))

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

def sieve(n):
    p = 0
    primes = []
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if(is_prime[i]):
            primes.append(i)
            p += 1
            for j in range(i*2,n,i):#iごとに増える
                is_prime[j] = False
    return p

if(__name__ == "__main__"):
    while(True):
        try:
            n = int(input())
        except:
            break
        print(sieve(n) + "\n")

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()