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


def nOfPrime(m):
    return m * 2


if __name__ == "__main__":
    while True:
        try:
            n = int(input())
            prm = 1
            nlist = []
            nlist2 = []
            plist = []

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

            while True:
                #print(nlist, " ", math.sqrt(n))
                if nlist[0] > math.sqrt(n):  # 終了条件
                    #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: try:
    while True:
        n = int(input())
        datasets = list(range(2, n+1))
        answers = set([])
        while datasets:
            i = datasets[0]
            datasets = filter(lambda data: data%i != 0, datasets)
            answers.add(i)
        print(len(answers))
except:
    pass

Python: import math, sys


def erastos(n):
    n += 1
    try:
        v = [0 if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else 1 for i in range(n)]
        v[0] = v[1] = 0
        v[2] = v[3] = v[5] = 1
    except IndexError:
        return [0, 0, 1, 1, 0, 1][:n]
    sqrt = math.sqrt(n)
    for serial in range(3, n, 2):
        if serial > sqrt:
            return v
        for s in range(serial ** 2, n, serial):
            v[s] = 0
if __name__ == '__main__':
    while True:
        try:
            n = int(input())
        except:
            break
        v = erastos(n)
        primes = [i for i, b in enumerate(v) if b == True]
        print(len(primes))

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

answer = [0] * 1000000
for i in range(2, 1000000):
    answer[i] += primes[i] + answer[i-1]

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

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(sum(prime[:n]))

Python: from sys import stdin

for Input in stdin :
    Input = int(Input)
    if (Input <= 10) : 
        if   (Input <= 1) : print(0)
        elif (Input == 2) : print(1)
        elif (Input == 3) or (Input == 4) : print(2)
        elif (Input == 5) or (Input == 6) : print(3)
        else : print(4)
    else :
        result = 4
        for make in range(11, Input + 1, 2) :
            if (make % 2 != 0) or (make % 3 != 0) or (make % 5 != 0) or (make % 7 != 0) : result += 1
        print(result)

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():
    prim_vals = {}                         # ????????°?????§????´???°????????°
    while True:
        num = sys.stdin.readline()
        if num is None or num.strip() == '':
            break

        num = int(num.strip())
        if prim_vals.get(num) is not None:
            cnt = prim_vals.get(num)
        else:
            #print('num:', num)
            if num == 1:
                cnt = 0
            else:
                cnt = 0
                #for i in range(3, num + 1, 2):
                if num % 2 == 0:
                    start_num = num -1
                else:
                    start_num = num
                    
                for i in range(start_num, 1, -2):
                    #print('i:', i)
                    if prim_vals.get(i) is not None:
                        cnt += prim_vals.get(i)
                        break
                    
                    if is_prime(i):
                        cnt += 1
                prim_vals[num] = cnt # ????????°?????§????´???°????????°????????????(2?????????)
                cnt += 1             # 2??????????¶????

        print(cnt)

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

Python: import sys

values = []
for line in sys.stdin:
    if 1000000 > int(line):
        values.append(int(line))

for val in values:
    prime = 0
    i = 2
    while i <= val:
        j = 2
        while j <= i:
            if i % j == 0:
                if j == i:
                    prime += 1
                else:
                    break
            j += 1
        i += 1
    print(prime)

Python: import sys
e=list(map(int,sys.stdin))
m=max(e)+1;a=[1]*m;a[0:2]=0,0
for i in range(2,int(m**.5)+1):
 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 x in e:print(a[x])

Python: def check_prime(goal):
    true_or_false=False
    for i in range(2,goal):
        if goal%i==0:
             true_or_false=True
             break
    if true_or_false==False:
        return True
    else:
        return False
anss=[]
while True:
    try:
        num=int(input())
        num_of_prime=0
        for i in range(2,num+1):
           if check_prime(i):
               num_of_prime+=1
        anss.append(num_of_prime)
    except:
        break
for ans in anss:
    print(ans)

Python: import sys

for user in sys.stdin:
    n = int(user)
    num = 1
    for i in range(2, n+1):  # ?´???°??¨??????????????°
        for j in range(2, i):  # ????????°
            if i % j == 0:
                break
            if j == i-1:
                num += 1

    print(num)

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