Go: package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = 1
        }
        primes[0] = 0
        primes[1] = 0
        Soe()
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := i*2; j < MAX; j+=i {
                                primes[j] = 0
                        }
                }
        }
}

Python: # PrimeNumber
# エラトステネスの篩

from itertools import product
import math

if __name__ == "__main__":
    while True:
        try:
            # 数値の入力があった
            n = int(input())
            nlist = []
            nlist2 = []
            plist = []

            # for i in range(2, n + 1):
            #    nlist.append(i)  # [2,3,4,5,6,...,n]
            nlist = range(2, n + 1, 1)

            while True:
                #print(nlist, " ", math.sqrt(n))
                sqrtn = math.sqrt(n)
                if nlist[0] > sqrtn:  # 終了条件
                    #plist.append(map(int,nlist))
                    plist.extend(nlist)
                    break
                else:
                    plist.append(nlist[0])

                    #i = 0
                    for j in nlist:
                        if j % nlist[0] != 0:
                            #nlist.pop(i)
                            #nlist.remove(j)
                            nlist2.append(j)
                            #i += 1
                    nlist = nlist2
                    nlist2 = []
            #print("fin: {}".format(plist))
            print(len(plist))

        except EOFError:
            break  # escape from while loop

pass
#

Python: # coding: utf-8
# Here your code !
import math
 
def is_prime_num(in_num):
    cnt = 0
    if in_num == 2:
        return True
    elif in_num <= 1:
        return False
    elif in_num % 2 == 0:
        return False
    else:
        if pow(2, in_num-1, in_num) == 1:
        
            max_num = int(math.sqrt(in_num)+1)
            for j in range(3, max_num, 2):
                if in_num % j == 0:
                    cnt = cnt + 1
                    break
                         
            if cnt == 0:
                #??´????°
                return True
            else:
                return False
        else:
            return False

while True:
    try:
        n = int(input())
        prime_cnt = 0
 
        for i in range(2, n+1):
            if is_prime_num(i):
                #??´????°
                prime_cnt = prime_cnt + 1
                 
 
        print(str(prime_cnt))
    except:
        break

Python: import sys
import math
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
for i in range(5,B,6):
    p = (i-5)//6
    k = p+i
    ini = (i*5-1)//6
    if l[p] == 1:
        l[k::i] = [0] * len(l[k::i])
        m[ini-1::i] = [0] * len(m[ini-1::i])
    if m[p] == 1:
        m[k+2::i+2] = [0] * len(m[k+2::i+2])
        l[ini+1::i+2] = [0] * len(l[ini+1::i+2])

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

Python: import numpy
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break
def primesfrom3to(n):
    sieve = numpy.ones(int(n/2), dtype=numpy.bool)
    for i in range(3,int(n**0.5)+1,2):
        if sieve[int(i/2)]:
            sieve[int(i*i/2)::int(i)] = False
    return 2*numpy.nonzero(sieve)[0][1::]+1
if __name__ == "__main__":
    array = list(get_input())
    for i in range(int(len(array))):
        primeList = list(primesfrom3to(int(array[i])))
        primeList.insert(0,2)
        print(len(primeList))

Python: # coding: utf-8

import sys
import math

max = 11
prime = [2,3,5,7,11]

for line in sys.stdin:
    
    n = int(line)
    
    if n > max:
        for m in range(max + 1, n + 1):
            flag = 1
            
            if m % 2 == 0:
                flag = 0
            else:
                for p in prime:
                    if p > math.sqrt(m):
                        break
                    if m % p == 0:
                        flag = 0
                        break
            
            if flag == 1:
                prime.append(m)
        
        max = n
    
    count = 0
    for i in prime:
        if i > n:
            break
        count += 1
        
    print(count)

Python: plst = [1 for i in range(1000001)]
plst[0] = plst[1] = 0
for i in range(2,1000001):
  if plst[i] == 1:
    for j in range(i * 2,1000001,i):
      plst[j] = 0
while True:
  try:
    print(sum(plst[:int(input()) + 1]))
  except EOFError:
    break

Python: import sys
a=[0,0,1]+[1,0]*5*10**5
for i in range(4,999):
 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
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 math

def prime_judge(n):
    if n==1:
        return False
    elif n==2:
        return True
    elif n%2==0:
        return False
    else:
        sqrt_num=math.ceil(math.sqrt(n))+1
        for i in range(3,sqrt_num, 2):
            if n%i==0:
                return False
        return True

def prime_count(n):
    count=0
    for i in range(1,n+1):
        if prime_judge(i):
            count+=1
    print(count)

while 1:
    try:
        prime_count(int(input()))        
    except:
        break

Python: # coding: utf-8

import math

def sieve_of_erastosthenes(input_list):

    for num in input_list:
        if 2 > num:
            return 0

        serial_number_list = [r for r in range(2, num + 1)]
        multiple_list = []
                
        while math.sqrt(num) >= serial_number_list[0]:
            i = 1

            serial_number = serial_number_list[0]
      
            multiple_list.append(serial_number)
                        
            while serial_number_list[len(serial_number_list) - 1] >= 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))

if __name__ == '__main__':
    input_list = []

    while True:
        try:
            input_list.append(int(input()))
        except:
            break

    sieve_of_erastosthenes(input_list)

Python: numlist=[0,0,1]+[0]*999998
for i in range(3,1000000,2):
    numlist[i]=1
for i in range(3,1000,2):
    if numlist[i]==1:
        for j in range(i*i,1000000,i):
            numlist[j]=0

cnt=[0,0,1]+[0]*999999
count=1
for i in range(3,1000000,2):
    if numlist[i]:
        count+=1
    cnt[i]=cnt[i+1]=count
while True:
    try:
        n=int(input())
        print(cnt[n])
    except:
        break

Python: import math

num_max = 999999
i = 3
prime_list = [2]
while i<num_max :
	judge = True
	j = 0
	while prime_list[j] <= math.sqrt(i) :
		if (i%prime_list[j]==0) :
			judge = False
			break
		j += 1
	if(judge) :
		prime_list.append(i)
	i += 2
while True :
    try:
        n = input()
        k = 0
        while prime_list[k] <=  n :
            k += 1
        print(k)
    except EOFError :
        break