Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func check(n int) int {
	eratos := make([]bool, n+1)
	cnt := 0
	for i := 2; i < len(eratos); i++ {
		if !eratos[i] {
			cnt++
			for j := i*i; j < len(eratos); j += i {
				eratos[j] = true
			}
		}
	}
	return cnt
}

func main() {
	for scanner.Scan() {
		n := nextInt()
		fmt.Println(check(n))
	}
}

Python: import sys


def isp(n):
    a = 1
    for i in range(2, (n + 1) // 2 + 2):
        if not n % i:
            a = 0
            break
    return a


ary = []
for i in sys.stdin:
    ary.append(int(i))

for i in ary:
    if i == 2:
        print(1)
    elif i == 3:
        print(2)
    else:
        s = 2
        for x in range(2, i + 1):
            if isp(x):
                s += 1
        print(s)

Python: #0009
a = []
l = [2]
while True:
    try:
        a.append(int(input()))
    except:
        break

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
    
z = primes(max(a))


for k in a:
    y = len([x for x in z if x <= k])
    print(y)

Python: import sys
def isPrime(i):
    if i<2:
        return False
    else:
        for j in range(2,i):
            if j*j>n:
                break
            elif i%j==0:
                return False
        return True

def countPrime(i):
    cnt=0
    for x in range(2,i+1):
        if isPrime(x) == True:
            print(x)
            cnt+=1
    return cnt

for line in sys.stdin:
    n=int(line)
    cnt=0
    for x in range(2,n+1):
        if isPrime(x)==True:
            cnt+=1
    print(cnt)

Python: import sys
def PrimNum(p):
    i = 0
    while True:
        if len(l) <= i: break
        if l[i] > p: break
        i+=1
    return i
def PrimeList(p) -> list:
    if p == 2: return 1
    elif p > 2:
        l = list(range(2, p+1))
        i = 0
        while pow(l[i], 2) <= p:
            # 2~pまでの数字の表を作って、2からpに向けて一つずつその倍数となる数を消していく。消されずに残っているものは素数である。
            # 入力の内の最大数のみを取り出して、この関数にかける。他の値はリストの中から
            l = [ l[j] for j in range(0, len(l)) if j <= i or l[j] % l[i] != 0] 
            i+=1
    return l
a = [int(line) for line in sys.stdin]
l = PrimeList(max(a)) # 最大値のみを渡す
for i in a: print(PrimNum(i))

Python: def isprime(num):
   i = 2
   count = 0
   while i< num:
       if num % i == 0:
           count += 1
       i += 1
   if count == 0:
       return 1
   else:
       return 0
ch = 0
while ch != 26:
   if(ch == 26):
      exit()
   num = int(input())
   count_prime = 0
   for i in range(2,num+1):
       if(isprime(i) == 1):
           count_prime += 1
   print(count_prime)

Python: import sys

N = 1000000
lst = [1] * N
for i in range(3, int(N**0.5), 2):
    if lst[i]:
        lst[i*i::2*i] = [0] * len(lst[i*i::2*i])
lst = [2] + [i for i in range(3, N, 2) if lst[i]]
for i in sys.stdin:
    for j in range(len(lst)):
        if lst[j] > int(i):
            print(j)
            break

Python: import sys, math

class Eratos(object):
    def __init__(self, N):
        self.N = N
        self._primes = {i:True for i in range(2, N+1)}

    def filter(self):
        end = self.N
        if self.N > 5:
            end = math.ceil(self.N**0.5) + 1
        for n in range(2, end):
            if not self._primes[n]:
                continue
            for x in range(n*2, self.N+1, n):
                if x in self._primes:
                    self._primes[x] = False
    
    def primes(self, x):
        return [k for k,v in self._primes.items() if v == True and k <= x]

def run():
    e = Eratos(999999)
    e.filter()
    for _n in sys.stdin:
        N = int(_n)
        print(len(e.primes(N)))

if __name__ == '__main__':
    run()

Python: import sys

num_of_data = 0

while True:
    if num_of_data >= 30:
        break
    try: 
        n = int(input())
        if n >= 1 and n <= 999999:
            cnt = 0
            for i in range(1, n+1):
                flag = 0
                for j in range(1, i+1):
                    if i%j == 0:
                        flag += 1
                if flag == 2:
                    cnt += 1

            print(cnt)
            num_of_data += 1
    
    except EOFError:
        sys.exit()

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] < math.ceil(math.sqrt(line)) + 1 :
        pList.append(sList.pop())
        for p in pList:
            sList = list(filter(lambda i: i % p != 0, sList))
    print(len(sList) + len(pList) + 1)

Python: import sys,random

rand = random.randint

def prime(n):
	if n == 2:
		return True
	if n < 2 or n & 1 == 0:
		return False
	d = (n-1) >> 1
	while d & 1 == 0:
		d >>= 1
	
	for i in range(2):
		a = rand(1,n-1)
		t = d
		y = pow(a,t,n)
		while t != n-1 and y != 1 and y != n-1:
			y = pow(y,2,n)
			t <<= 1
		if y != n-1 and t & 1 == 0:
			return False
	return True

a = [prime(i) for i in range(1000000)]

for s in sys.stdin:
	i = int(s)
	print(a[:i+1].count(True))

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 sys

def prime_calc(n):
    if n < 2:
        return 0
    else:
        i = 2
        while i*i <= n:
            if n % i == 0:
                return 0
            else:
                i = i + 1

    return 1

def prime(n):
    cnt = 0
    for i in range(1, n+1):
        ans = prime_calc(i)
        if ans == 1:
           cnt = cnt + 1

    return cnt

def main():
    l = []

    for line in sys.stdin:
        l.append(int(line))

    for line in l:
        print(prime(line))

if __name__ == "__main__":
    main()

Python: import sys
def isprime(num):
   i = 2
   count = 0
   while i< num:
       if num % i == 0:
           count += 1
       i += 1
   if count == 0:
       return 1
   else:
       return 0
for line in sys.stdin:
   num = int(input())
   count_prime = 0
   for i in range(2,num+1):
       if(isprime(i) == 1):
           count_prime += 1
   print(count_prime)
else:
   exit()

Python: def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
t=0
while t == 0:
    try:
        x = int(input())
    except:
        break
    else:
        n = 1
        if x == 0 or 1:
            print(0)
        elif x == 2:
            print(1)
        else:
            for i in range(0,x + 1,2):
                if is_prime(i):
                    n += 1
            print(n)

Python: def isprime(num):
    if num==1:return False
    if num==2:return True
    for i in range(int(num/2)):
        if num%(i+2)==0:
            return False
        else:continue
    return True
    
def ct(num):
    count=0
    for i in range(num):
        if isprime(i+1):count+=1
    return count

def yak(num):
    if isprime(num):return [1,num]
    if num==1: return[1]
    for i in range(int(num/2)):
        if num%(i+2)==0:
            ret=yak(i+2)+yak(num/(i+2))
            ret.remove(1)
            return sorted([int(i) for i in ret])
    
        
while True:
    try:raw=[int(i) for i in input().split(" ")]
    except:break
    a=raw[0]
    print(str(ct(a)))