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: from math import *
search_list = []
search_list_ref = []
prime_list = []
prime_list_ref = []
target1,target2,num = 0,0,2
i,j,k = 0,0,0
flag = 0
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break
if __name__ == "__main__":
    array = list(get_input())
    print("/*------------------------------------*/")
    for i in range(len(array)):
        print(str(array[i]) + "?????????????´???°????±??????????")
    #??\????????¨?????????????????????????????§?´???°????????°?????¢?´¢??????
        #?????????sqrt(int(array[i]))?????§????????§?´???°??????????????????
        ref_target = int(sqrt(int(array[i])))
        search_list_ref.append(2)
        search_list_ref.append(ref_target)
        while target1 < ref_target:
            if search_list_ref == []:
                break
            prime_list_ref.append(search_list_ref[0])
            target1 = search_list_ref[0]
            search_list_ref.remove(target1)
            if target1 > ref_target:
                break
            num = target1
            if target1 == 2:
                for num in range(2,ref_target):
                    if (num % target1 != 0):
                        search_list_ref.append(num)
                if ref_target != 3:
                        search_list_ref.remove(ref_target)
            else:
                for j in search_list_ref:
                    if j % target1 == 0:
                        search_list_ref.remove(j)

        prime_list_ref = prime_list_ref + search_list_ref
        search_list.append(2)
        search_list.append(int(array[i]))

        #?????????????????¬??\?±????????????°?????????????´???°????±??????????
        while target2 < sqrt(int(array[i])):
            prime_list.append(search_list[0])
            target2 = search_list[0]
            search_list.remove(target2)
            if target2 > sqrt(int(array[i])):
                break
            num = target2
            if target2 == 2:
                for num in range(2,int(array[i])):
                    for k in prime_list_ref:
                        if num % k != 0:
                            flag = 1
                        else:
                            flag = 0
                            break
                    if flag == 1:
                        search_list.append(num)
                search_list.remove(int(array[i]))
                prime_list_ref.pop(0)
                search_list[1:1] = prime_list_ref
                break
            elif target2 not in prime_list_ref:
                for j in search_list:
                    if j % target2 == 0:
                        search_list.remove(j)
                break
            else:
                pass
        prime_list = prime_list + search_list
        #print(array[i] + "??\???????´???°????????°???" + str(len(prime_list)))
        print(str(len(prime_list)))
        del search_list_ref[:]
        del prime_list_ref[:]
        del search_list[:]
        del prime_list[:]
        target1 = 0
        target2 = 0
        print("/*------------------------------------*/")

Python: import math

P = []
# 素数一覧リスト
Max = 1000000

def Era(P, Max) :
    D = list(range(2, Max))
    limit = math.sqrt(Max)
    while True :
        p = D[0]

        if limit <= p :
            P += D
            return P

        P.append(p)
        D = [d for d in D if d % p != 0]
        # D に含まれる値かつ p で割り切れない値をリスト化

Era(P, Max)

while True :
    try :
        n = int(input())

        if n == 1 :
            print(0)
        elif n == 2 :
            print(1)
        elif n >= max(P) :
            print(len(P))
        else :
            for i in range(n + 1) :
                if P[i] == n :
                    print(i + 1)
                    break
                elif P[i] > n :
                    print(i)
                    break

    except :
        break

Python: from math import sqrt
from sys import stdin

def isprime(x) :
    if x == 2 : return x
    elif (x < 2) or (x % 2 == 0) : return False
    else :
        i = 3
        while i <= sqrt(x) :
            if x % i == 0 : return False
            i = i + 2
    return x

for Input in stdin :
    result = []
    for make in range(2, int(Input) + 1) :
        if isprime(make) != False : result.append(make)
    print(len(result))

Python: import math
while True:
    try:
        n=int(input())
        num=list(range(n+1)) #[0,1,,,,n]が出力される
        num[1]=0
        for i in range(n):
            if num[i]>pow(n,0.5):
                break
            if num[i]==0:
                continue
            for j in range(num[i]*2, n+1, num[i]): #num[i]*2からn+1までnum[i]個飛ばしで
                num[j]=0
        print(n+1-num.count(0))
    except:
        break

Python: import sys
for limit in sys.stdin:
    limit = int(limit)
    arr = [2,3,5,7]
    def PrimeNumber(arr,number):
        for i in arr:
            if (number%i==0):
                return False
        return True

    for i in range(2,limit+1):
        if(PrimeNumber(arr,i)):
            arr.append(i)

            
    count = 0
    for i in arr:
        if (i>limit):
            break
        else:
            count += 1
        
    print(count)

Python: from math import sqrt
from sys import stdin

def isprime(x) :
    i = 3
    while i <= sqrt(x) :
        if x % i == 0 : return False
        i = i + 2
    return x

for Input in stdin :
    if int(Input) == 1 : print(0)
    elif int(Input) == 2 : print(1)
    else:
        result = 1
        for make in range(3, int(Input) + 1, 2) :
            if isprime(make) != False : result += 1
        print(result)

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: # ?´???°?????°?????¨?????????????????°??????

import sys
import math

prim_no = {2: True}                    # ????????°????´???°??§??????????????????????????????

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

        print(cnt)

if __name__ == '__main__':
    main()
    #print(prim_no)