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: # coding=utf-8
import array


def sieve_of_eratosthenes(end: int) -> array:
    # noinspection PyUnusedLocal
    is_prime = array.array('B', (True for i in range(end+1)))
    is_prime[0] = False
    is_prime[1] = False

    primes = array.array("L")
    for i in range(2, end+1):
        if is_prime[i]:
            primes.append(i)
            for j in range(i * 2, end+1, i):
                is_prime[j] = False
    return primes


if __name__ == '__main__':
    prime_table = sieve_of_eratosthenes(1000000)
    while True:
        try:
            n = int(input())
        except EOFError:
            break
        prime_table_under_n = [x for x in prime_table if x <= n]
        print(len(prime_table_under_n))

Python: def p(n):
    l = list(range(2,n+1))
    p = 2
    i = 0
    p = l[i]
    while True:
        pl = len(l)
        l = list(filter(lambda n: n%p != 0 or n == p,l))
        i += 1
        p = l[i]
        if pl == len(l):
            break
    return len(l)

from sys import stdin
for i in stdin:
    print(p(int(i)))

Python: import math

def yo(n):
    if n==1:    return False
    s=2
    while s <= int(math.sqrt(n)):
        if n%s == 0:    return False
        s+=1
    return True

while True:
    c=0
    try:
        for i in range(1, int(input())+1):
            if yo(i)==True:    c+=1
        print(c)
    except:
        break

Python: import math

while(1):
    try:
        n = int(input())
    except:
        break

    m = int(math.sqrt(n))
    keys = [n // i for i in range(1, m+1)]
    keys += range(keys[-1]-1, 0, -1)
    h = {i: i-1 for i in keys}

    for i in range(2, m+1):
        if h[i] > h[i-1]:
            hp = h[i-1]
            i2 = i*i
            for j in keys:
                if j < i2:
                    break
                h[j] -= h[j // i] - hp
    print(h[n])

Python: from math import sqrt
cash = {}
def isprime(n):
    if n in cash:
        return cash[n]
    if n == 1:
        return 0
    if n == 2:
        return 1
    if n % 2 == 0:
        return 0
    for i in range(2,int(sqrt(n)+1)):
        if n % i == 0:
            return 0
    cash[n] = 1
    return 1

from sys import stdin
h = {}
for i in stdin:
    i = int(i)
    c = sum(isprime(n) for n in range(2,i+1))
    print(c)

Python: import sys

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

for val in values:
    prime = 0
    for i in range(2, val // 2):
        if val % i != 0:
            prime += 1
    print(prime)

Python: import sys
a=[0,0]+[1]*10**6
for i in range(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: while 1:
    try:
        count=0;
        x=int(input())
        if x==1:
            print(0)
        elif x==2:
            print(1)
        else:
            a=[int(i) for i in range(2,x+1)]
            for i in  range(len(a)):
                count1=0
                for j in range(2,a[i]):
                    if a[i]%j==0:
                        count1+=1
                if count1==0:
                    count+=1
            print(count)        
    except EOFError:
        break

Python: try:
    while True:
        n=int(input())
        nums = range(2, n+1)
        res = list(range(2, n+1))
        for a in nums:
            if a in res:
                tmp = []
                for b in res:
                    if b<=a or b % a != 0:
                        tmp.append(b)
                res = tmp
        print(len(res))
except:
    pass

Python: import sys
import math

lines = str(sys.stdin.read()).strip().split("\n")

for line in lines:
    line = int(line)
    pList = []
    sList = list(reversed(list(range(3, line + 1))[::2]))
    while sList[-1] < int(math.ceil(math.sqrt(line))) + 1 :
        pList.append(sList.pop())
        for p in pList:
            sList = list(filter(lambda i: i % p != 0, sList))
    pList.extend(sList)
    pList.append(2)
    print(len(pList))

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
    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 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: while True:
    try:
        n=int(input())
    except:
        break
    print(sum(i==2 or pow(2,i-1,i)==1 for i in range(2,n+1)))

Python: import sys
import math

N = 1000000
primes = [1] * (N//2+1)
primes[0] = 1

for i in range(3,int(math.sqrt(N))+1,2):
    if primes[i//2]:
        primes[(i*i)//2::i] = [0] * len(primes[(i*i)//2::i])
    primes[i//2] += primes[i//2-1]

for i in range(int(math.sqrt(N))+1,N+1,2):
    primes[i//2] += primes[i//2-1]


for i in sys.stdin:
    n = int(i)
    if n == 1:
        print(0)
    elif n == 2:
        print(1)
    else:
        print(primes[(n-1)//2])

Python: # coding: utf-8

import math

def sieve_of_erastosthenes(num):

    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

    return len(multiple_list + serial_number_list)

if __name__ == '__main__':
    input_list = []
    
    while True:
        try:
            print(sieve_of_erastosthenes(int(input())))
        except:
            break