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

MAX = 999999
L = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]

def is_prime(n):
  if n == 2:return True
  if n % 2 == 0:return False
  for i in range(3,int(n**0.5)+1,2):
    if n % i == 0:return False
  return True

def is_prime_2(n):
  a = int(n ** 0.5)
  for i in L:
    if i > a:return True
    if n % i == 0:return False
  return True

def prime_count(n):
  result = 0
  if n >= 2:result+=1
  for i in range(3,n+1,2):
    if is_prime_2(i):result+=1
  return result

def prime_list(n):
  result = []
  if n >= 2:result.append(2)
  for i in range(3,n+1,2):
    if is_prime(i):result.append(i)
  return result

L2 = prime_list(MAX)

def prime_count_2(n):
  for i,v in enumerate(L2):
    if v > n:return i
  return len(L2)

for n in sys.stdin:
  print(prime_count_2(int(n)))

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

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

for line in sys.stdin:
    n=int(line)
    print(countPrime(n))

Python: def e(n):
    array = [1]*(n+1)
    k = 2
    while k*k <= n:
        if array[k] == 1:
            i = k
            while (i <= n/k):
                array[k*i] = 0
                i += 1
        k += 1
    prime = []
    i = 2
    while i <= n:
        if array[i] == 1:
            prime.append(i)
        i += 1
    return len(prime)
while True:
    try:
        n = int(input())
        print(e(n))
    except:
        break

Python: import math
while True:
    try:
        n=int(input())
        num=list(range(n+1)) #[0,1,,,,n]が出力される
        num[1]=0
        for i in range(n):
            if num[i]>pow(n,0.5):
                break
            if num[i]==0:
                continue
            for j in range(num[i]*2, n+1, num[i]): #num[i]*2からn+1までnum[i]個飛ばしで
                num[j]=0
        print(n+1-num.count(0))
    except:
        break

Python: 
a=int(input())
X=[i for i in range(2,a+1)]
while True:
  X=[i for i in X if i % Y[0] !=0 ]
  if X == Y:
    break
  Y=X[:]

print(len(X))

Python: import math
import sys

def prime_calc(n):
    rootN = math.floor(math.sqrt(n))
    prime = [2]
    data = [i + 1 for i in range(2,n,2)]
    while True:
        p = data[0]
        if rootN <= p:
            return len(prime + data)
        prime.append(p)
        data = [e for e in data if e % p != 0]

def main():
    l = []

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

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

if __name__ == "__main__":
    main()

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: limit = int(input(""))
def primeNumber(number):
    count = 0
    for i in range(2,number+1):
        if (number%i==0):
            count = count + 1
    if (count==1):
        return True
    else:
        return False

sum = 0
for i in range(2,limit+1):
    if (primeNumber(i)):
        sum = sum + 1

print(sum)

Python: def pri(n):
    s=[True for _ in range(n+1)]
    i=2
    while i**2<=n:
        if s[i]:
            j=i*2
            while j<=n:
                s[j]=False
                j+=i
        i+=1

    tab=[i for i in range(n+1) if s[i] and i>=2]
    return(tab)


while True:
    try:
        print(len(pri(int(input()))))
    except:
        break

Python: # -*- coding: utf-8 -*-

while True:
    try:
        n = int(raw_input())
        if n < 2:
            print(0)
            continue
        list1 = range(2, n + 1)
        list2 = []
        while True:
            i = list1.pop(0)
            list2.append(i)
            for x in list1:
                if x % i == 0:
                    list1.remove(x)
            if len(list1) == 0:
                break
            if i**2 > sorted(list1,lambda n1, n2:n2 - n1)[0]:
                break
        print(len(list2 + list1))
    except EOFError:
        break

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 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]]

if __name__ == "__main__":
    while True:
        try:
            n = int(input())
            print(len(primes(n)))
        except:
            break

Python: import sys
def isPrime(i):
    if i<2:
        return False
    else:
        for j in range(2,i):
            if j*j>i:
                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

while True:
    try:
        n=int(input())
        cnt=0
        for x in range(2,n+1):
            if isPrime(x)==True:
                cnt+=1
        print(cnt)
    except:
        break