Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var primeCount int
	for sc.Scan() {
		input := nextInt()
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		fmt.Printf("%d\n", primeCount)
		primeCount = 0
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2:
		return true
	case num < 2 || num%2 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

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

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

Python: import sys
import math
import bisect

M = 1000000
B = int(math.sqrt(M)+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
o = []
for i in range(5,B,6):
    p = (i-5)//6
    ini = (i*5-1)//6
    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])

for i in range(N1):
    if l[i] == 1:
        o.append(6*i+5)
    if m[i] == 1:
        o.append(6*i+7)

if N2>N1 and m[N1] ==1:
    o.append(6*N1+7)

for i in sys.stdin:
    n = int(i)
    r =  n-1 if n < 4 else bisect.bisect_right(o, n)+2
    print(r)

Python: def sieve(n):
	p=[True for i in range(n+1)]
	p[0]=p[1]=False
	for i in range(2,n+1):
		if p[i]==True:
			for j in range(i*i,n+1,i):
				p[j]=False
	return p

def solve(n):
		if n<2:return 0
		c=1
		for i in range(3,n+1,2):
			if p[i]==1:
				c+=1
		return c

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

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

Python: x = [1 for i in range(10 ** 6 + 1)]
x[0] = x[1] = 0
for i in range(10 ** 6 + 1):
  if x[i] == 1:
    for j in range(i * 2, 10 ** 6 + 1, i):
      x[j] = 0
while 0 == 0:
  try:
    n = int(input())
    c = 0
    for i in range(n + 1):
      c += x[i]
    print(c)
  except EOFError:
    break

Python: import sys

f = [1, 0, 0, 0, 1, 0] * (1000000 // 6 + 1)
f = [0, 0, 1, 1] + f[3:-2]

i = 5
while i < 1000:
    if f[i] == 1:
        j = i * i
        while j <= 1000000:
            f[j] = 0
            j += i + i
    i += 2

for n in sys.stdin:
    i = int(n)
    print(sum(f[:i + 1]))

Python: import sys
import math

def isPrime(x):
    if x == 2:
        return True
    if x < 2 or x%2 == 0:
        return False
    for i in range(3,int(math.sqrt(x))+1,2):
        if x%i == 0:
            return False
    return True

if __name__ == '__main__':
    a = []
    for tmp_line in sys.stdin:
        n = (int)(tmp_line)
        a.append(n)
    primes = []
    for x in range(2,max(a)+1):
        if isPrime(x):
            primes.append(x)
    for y in a:
        print(len([x for x in primes if x <= y]))

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])
[print([e-1,sum(a[:(e+1)//2])][e>3])for e in map(int,sys.stdin)]

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

import sys
import math

prim_no = {}                    # ????????°????´???°??§??????????????????????????????

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())
        cnt = 0
        for i in range(2, num + 1):
            if is_prime(i):
                cnt += 1

        print(cnt)

if __name__ == '__main__':
    main()

Python: def isPrime(x):
    if x==2:
        return True
    if x<2 or x%2==0:
        return False
    if pow(2,x-1,x)==1:
        return True
    else:
        return False
while 1:
    try:
        n=input()
        ct=1
        if n==2:
            print(1)
        else:
            for i in xrange(3,n+1,2):
                if isPrime(i):
                    ct+=1
            print(ct)
    except:
        break

Python: import sys
def prime(n):
  l = [2]
  for i in range(3,n+1):
    count = 0
    for j in l:
      if i % j == 0:
        count += 1
    if count == 0:
      l.append(i)
  return l
for line in sys.stdin.readlines():
  n = int(line)
  if n == 1:
    print(0)
  else:
    print(len(prime(n)))

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

import sys
import os
import math



def eratosthenes(n):
    lst = [i for i in range(2, n+1)]
    primes = []
    sqrt_n = n ** 0.5

    while lst:
        first = lst.pop(0)
        if first < sqrt_n:
            primes.append(first)
            new_lst = []
            for v in lst:
                if v % first != 0:
                    new_lst.append(v)
            lst = new_lst
        else:
            # ??????
            return primes + [first] + lst

for s in sys.stdin:
    n = int(s)
    lst = eratosthenes(n)
    print(len(lst))

Python: import math
MAX = 1000000
A = [1]*MAX

for i in range(2,int(math.sqrt(MAX))+1):
    if A[i]==1:
        for j in range(2*i,MAX,i):
            A[j]=0
A[0]=0
A[1]=0
for i in range(1,MAX):
    A[i] += A[i-1]

while True:
    try:
        n = int(input())
    except:
        break
    print(A[n])

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 a[:int(e)]if i]))

Python: is_prime = [False,False]

for i in range(2,1000000):
    is_prime.append(True)

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


n_prime = [0,0]
cnt = int(0)

for i in range(2,1000000):
    if is_prime[i]:
        cnt += 1
    n_prime.append(cnt)

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

Python: def e(n):
    array = [1]*(n+1)
        
    k = 2
    
    while k*k <= n:
        if array[k] == 1:
            i = k
    
            while (i <= n/k):
                array[k*i] = 0
                i += 1
        
        k += 1
    
    # ?´???°(array[i]==1)?????????
    prime = []
    i = 2
    
    while i <= n:
        if array[i] == 1:
            prime.append(i)
        i += 1
    
    return len(prime)


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

Python: is_prime=[True for i in range(1000000+1)]
is_prime[0]=is_prime[1]=False
for i in range(2,1000):
	if not is_prime[i]:
		continue
	for j in range(2,int(1000000/i)+1):
		is_prime[i*j]=False
cnt=0
primepi=[0 for i in range(1000000)]
for i in range(1000000):
	if is_prime[i]:
		cnt+=1
	primepi[i]=cnt

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

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

Python: import sys

l = [True] * 100000
for i in range(2, 100000):
    if (l[i - 1]):
        for j in range(i ** 2 - 1, 100000, i):
            l[j] = False
for n in sys.stdin:
    print(l[1:int(n)].count(True))