Go: package main

// https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}
		maybePrime := make([]bool, n+1)
		for i := 0; i <= n; i++ {
			maybePrime[i] = true
		}

		maybePrime[0] = false
		maybePrime[1] = false
		for i := 2; i <= int(math.Sqrt(float64(n)))+1; i++ {
			j := i * 2
			for j <= n {
				maybePrime[j] = false
				j += i
			}
		}

		nPrimes := 0
		for _, p := range maybePrime {
			if p {
				nPrimes++
			}
		}
		// fmt.Println(maybePrime)
		fmt.Println(nPrimes)
	}
}

Python: import sys
results = {}
def fact(n):
    if n in results:
        return results[n]
    ret = [1]
    if n%2==0:
        ret.append(2)
        results[n]=ret
        return ret
    for i in range(3,int(n**0.5)+1,2):
        if n%i==0:
            ret.append(i)
            results[n]=ret
            return ret
    results[n]=ret
    return ret
prime_results = {}
def isPrime(n):
    if n in prime_results:
        return prime_results[n]
    if n<=1:
        return False
    if n==2:
        return True
    if fact(n)==[1]:
        prime_results[n]=True
        return True
    else:
        prime_results[n]=False
        return False
lines = sys.stdin.readlines()
for line in lines:
    inp = int(line)
    s=0
    for i in range(2,inp+1):
        if isPrime(i):
            s+=1
    print (s)

Python: from math import sqrt

I_list=[]

#input syutoku

while True:

	try:

		k=int(input())

		I_list.append(k)

	except:

		break



I_max=max(I_list)

#create list (I_max=100 -> [3,5,7,...,99])

odd_list=[x for x in range(3,I_max+1,2)]

#print(W_list)



P_list=[2]



p=0

#print(I_list)

ct=0

while p<=int(sqrt(I_max)):

	p=odd_list.pop(0)

	P_list.append(p)

	P_baisuu=[p*x for x in range(1, int(I_max/p) +1 )]

	K_list=set(odd_list)-set(P_baisuu)

	odd_list=sorted(list(K_list))

#	print("P_list=")

#	print(P_list)

#	print("odd_list=")

#	print(odd_list)



prime_list=P_list+odd_list

#print("prime_list=")

#print(prime_list)



for i in I_list:

	w=[j for j in prime_list if j<=i ]

	print(len(w))

Python: import sys

def prime(n):
    N = n + 1
    ints = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(N)]
    try:
        ints[0] = ints[1] = False
        ints[2] = ints[3] = ints[5] = True
    except IndexError:
        pass
    sqrt = N ** 0.5

    for i in range(3, N, 2):
        if i >= sqrt:
            break
        for m in range(i ** 2, N, i):
            ints[m] = False
    return ints.count(True)

for line in sys.stdin:
    print(prime(int(line)))

Python: import sys
m=166666;a=[[1]*m for _ in[0]*2]
for i in range(m):
 if a[0][i]:
  k=6*i+5
  a[0][i+k::k]=[0]*len(a[0][i+k::k])
  a[1][-2-i+k::k]=[0]*len(a[1][-2-i+k::k])
 if a[1][i]:
  k=6*i+7
  a[0][-2-i+k::k]=[0]*len(a[0][-2-i+k::k])
  a[1][i+k::k]=[0]*len(a[1][i+k::k])
for e in map(int,sys.stdin):
 print([e-1,sum(a[0][:(e+1)//6]+a[1][:(e-1)//6])+2][e>3])

Python: 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 is_prime[i] == False:
            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]]

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

Python: from math import sqrt
from sys import stdin

def pm(n):
    l = list(range(3,n+1)[0::2])
    p = 3
    i = 0
    p = l[i]
    m = sqrt(n)+1
    while p <= m:
        l = l[:i+1] + [n for n in l[i+1:] if n%p != 0]
        i += 1
        p = l[i]
    return len(l) + 1

for n in stdin:
    print (pm(int(n)))

Python: import sys


def count_prime(n):
    global count, pool
    if not pool:
        return count
    p = pool[0]
    while p <= n:
        pool = tuple(i for i in pool if i % pool[0])
        count += 1
        if not pool:
            break
        p = pool[0]
    return count


inset = list(map(int, sys.stdin))
max_in = max(inset)
pool, count = tuple(range(3, max_in + 1, 2)), 1 if max_in > 1 else 0
inset = [(n, i) for i, n in enumerate(inset)]
inset.sort()
outset = [(t[1], count_prime(t[0])) for t in inset]
outset.sort()

print('\n'.join(map(str, [t[1] for t in outset])))

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

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

Python: import sys


def is_prime(n, primes):
    for prime in primes:
        if prime ** 2 > n:
            return True
        if n % prime  == 0:
            return False
    return True


def count_prime():
    primes = [2, 3]
    for i in range(5, 999999, 2):
        if is_prime(i, primes):
            primes.append(i)

    return primes

primes = count_prime()

for line in sys.stdin:
    n = int(line)
    count = 0

    for i in range(2, n+1):
        if i in primes:
            count += 1

    print(count)

Python: from math import sqrt
from sys import stdin
def pm(n):
    l = list(range(3,n+1)[0::2])
    p = 3
    i = 0
    p = l[i]
    m = sqrt(n)+1
    while p <= m:
        l = l[:i+1] + [n for n in l[i+1:] if n%p != 0]
        i += 1
        p = l[i]
    return len(l) + 1


for i in stdin:
    print(pm(int(i)))

Python: import sys
def fact(n):
    ret = [1]
    for i in range(2,int(n//2)+1):
        if n%i==0:
            ret.append(i)
    return ret
def isPrime(n):
    if n<=1:
        return False
    if n==2:
        return True
    if fact(n)==[1]:
        return True
    else:
        return False
lines = sys.stdin.readlines()
for line in lines:
    inp = int(line)
    s=0
    for i in range(2,inp+1):
        if isPrime(i):
            s+=1
    print (s)

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

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(line)
   count_prime = 0
   for i in range(2,num+1):
       if(isprime(i) == 1):
           count_prime += 1
   print(count_prime)
else:
   exit()

Python: import math

def Eratos(n):
	primes = [2]
	num = [2*i+1 for i in range(1,n//2)]
	tmp = []

	top = 1
	while top < math.sqrt(n):
		top = num[0]
		for i in range(1,len(num)):
			if num[i] % top != 0:
				tmp.append(num[i])
		num = tmp
		tmp = []
		primes.append(top)
	for i in range(len(num)):
		primes.append(num[i])
	return primes

def list_count(list_a,n):
	cont = 0
	for i in range(len(list_a)):
		if list_a[i] > n:
			break
		else:
			cont += 1
	return cont

primes = Eratos(1000000)
while True:
	try:
		n = int(input())
		print(list_count(primes,n))
	except EOFError:
		break

Python: import sys

for line in sys.stdin:
  try:
    n = int(line)
    primes = [2]
    for i in range(3, n + 1):
      primes.append(i)
      for p in primes:
        if i % p == 0 and i != p:
          primes.pop()
          break
    ans = [i for i in primes if i <= n]
    print(len(ans))
  except:
    break