Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		input := nextInt()
		fmt.Println(IsPrime(input))
	}
}

func IsPrime(num int) int {
	eratos := make([]bool, num+1)
	c := 0
	for i := 2; i < len(eratos); i++ {
		if eratos[i] == false {
			c++
			eratosCalc(i, eratos)
		}
	}
	return c
}

func eratosCalc(primeNum int, eratos []bool) {
	for i := primeNum * primeNum; i < len(eratos); i += primeNum {
		eratos[i] = true
	}
}

func next() string {
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

Python: from sys import stdin

def prime(n):
    Prime = [i for i in range(n + 1)]
    for i in range(2, n + 1):
        for j in range(2, int(n / i) + 1):
            Prime[i * j] = 0
    Prime[0], Prime[1] = 0, 0
    ans = [i for i in Prime if not (i == 0)]
    return len(ans)

Ans = []
for line in stdin:
    n = int(line)
    Ans.append(prime(n))
for po in Ans:
    print(po)

Python: from math import sqrt
def prime(n):
    if n == 2:
        return True
    elif n < 2 or n % 2 == 0:
        return False
    else:
        i = 1
        while p_list[i] <= sqrt(n):
            if n % p_list[i] == 0:
                return False
            i += 1
    return True
def p_count(n):
    c = 0
    for p in p_list:
        if(p > n):
            break
        c += 1
    return c

p_list = [2,3]
while True:
    try:
        n = int(input())
        for i in range(p_list[-1]+2,n+1,2):
            if (prime(i)):
                p_list.append(i)
        print(p_count(n))
    except:
        exit()

Python: m=10*6;a=[0]+[1]*m
for i in range(999):
 if a[i]:a[i*2+1::i+1]=[0 for e in range(len(li[i*2+1::i+1]))]
for e in sys.stdin:print(len([i for i in li[:int(e)]if i]))

Python: import math
import sys

def E(d):

    p_list = [] 
    tmp = []
    num = int(math.sqrt(len(d)))+1
    for i in d:
        i=d[0]
        if i>num:
            break
        else:
            p_list.append(i)
            for j in d:
                if j%i == 0:
                    d.remove(j)
        
    print(len(p_list)+len(d))
    # p_list.append(d)
    # return p_list

lists = []
for line in sys.stdin:
    x= list(range(2,(int(line)+1)))
    E(x)

Python: while True:
    try:
        Num = 1
        n = int(input())
        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)           
    except EOFError:
        break

Python: import sys
def prime(n):
  i = 2
  if n == 1:
    l = []
  else:
    l = [2]
  while i < n:
    i += 1
    for j in l:
      if i % j == 0:
        break
    else:
      l.append(i)
  return len(l)
for line in sys.stdin.readlines():
  n = int(line)
  print(prime(n))

Python: import sys
s=[2]
for i in range(3,999999):
	for j in range(2,i-1):
		if not i%j:break
	else:
		s.append(i)
		# print(i)
for n in sys.stdin:
	n=int(n)
	cnt=0
	for i,iv in enumerate(s):
		if iv>n:
			print(i)
			break
	else:
		print(i+1)

Python: def solve(n):
	A=[0 for i in range(n+1)]
	for i in range(2,n+1):
		cnt=0
		for j in range(1,i+1):
			if i%j==0:
				cnt+=1
		if cnt==2:#1??¨????????°??????
			A[i]=1
	cnt=0
	for i in A:
		if i==1:
			cnt+=1
	return cnt 

while True:
	try:
		n = int(input())
		print(solve(n))
	except EOFError:
		break

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(primeList)
        print(len(primeList))

Python: DP = [0,1,2]

while True:
    try:
        n = int(input())
        if len(DP) < n:
            for i in range(len(DP) + 1,n+1):
                YN = 0
                for j in range(2,i - 1):
                    if i % j == 0:
                        DP.append(DP[len(DP) - 1])
                        YN = 1
                        break
                    elif j ** 2 > i:
                        DP.append(DP[len(DP) - 1] + 1)
                        break

        print(DP[n - 1])
    except EOFError:
        break

Python: LIMIT = 10000000

isPrime = [True for _ in range(LIMIT)]

isPrime[0] = isPrime[1] = False

for i in range(2, int(LIMIT ** 0.5)+1):
  if isPrime[i]:
    for j in range(2 * i, LIMIT, i):
      isPrime[j] = False

countPrime = [0 for _ in range(LIMIT)]

for i in range(1, LIMIT):
  countPrime[i] = countPrime[i-1] + isPrime[i]

try:
  while True:
    n = int(input())
    print(countPrime[n])
except EOFError:
  pass

Python: kazu=[]
Max=1000000
def era(kazu,Max):
    sosu=list(range(2,Max))
    while True:
        num=sosu[0]
        if num>=Max**0.5:
            kazu+=sosu
            return kazu
        kazu.append(num)
        sosu=[i for i in sosu if i%num!=0]
era(kazu,Max)
while True:
    try:
        n=int(input())
        if n==1:
            print(0)
        elif n==2:
            print(1)
        elif n>=max(kazu):
            print(len(kazu))
        else:
            for i in range(n+1):
                if kazu[i]==n:
                    print(i+1)
                    break
                elif kazu[i]>n:
                    print(i)
                    break
    except EOFError:
        break

Python: # 準備
num_list = [0] * 1000000
i = 2
cnt = 0
for num in range(2,len(num_list)):
    if num_list[i] == -1:
        num_list[i] = num_list[i-1]
        i += 1
        continue
    cnt+=1
    num_list[i] = cnt
    # num_list[i*2::i] = -1
    for j in range(i*2,len(num_list),i):
        num_list[j] = -1
    i += 1

while True:
    try:
        n = int(input())
    except Exception as e:
        break
    print(int(num_list[n]))

Python: import math
import sys

def get_primes(n):
    search = list(range(2, n+1))
    primes = []
    while True:
        primes.append(search[0])
        for i,x in enumerate(search):
            if x % primes[-1] == 0:
                del search[i]
        if len(search) == 0:
            return primes
        if search[0] >= math.sqrt(n):
            primes.extend(search)
            return primes

for line in sys.stdin.readlines():
    n = int(line)
    if n < 2:
        print(0)
    else:
        print(len(get_primes(n)))

Python: # returns the number of prime numbers less than or equal to n
def sieve(n):
    prime = [True] * (n+1)
    prime[0] = prime[1] = False
    count = 0
    for i in range(2, n+1):
        if prime[i]:
            count += 1
            for j in range(2*i, n+1, i):
                prime[j] = False
    return count


while True:
    try:
        n = int(input())
        print(sieve(n))
    except:
        break