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

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


lst = [i for i in range(2, max(num)+1)]
for i in lst[::-1]:
    for j in range(2, i):
        if i % j == 0:
            lst.pop(lst.index(i))
            break

for i in num:
    for j in lst:
        if i < j:
            print(lst.index(j))
            break
        elif i == j:
            print(lst.index(j)+1)
            break

Python: import numpy
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break
def primesfrom3to(n):
    #?????????n/2??????1byte??????data type = True or False??§??¨???1??§??????
    sieve = numpy.ones(int(n/2), dtype=numpy.bool)
    if n%2 != 0:
        sieve = numpy.append(sieve,n/2)
    #i??????3??????2??????????????????n?????????????????§??????
    for i in range(3,int(n**0.5)+1,2):
        #???????????¶=sieve???True or False??§??¨????????????????????¶??????????????????????´???°?????????????????¶?????\??????
        if sieve[int(i/2)]:
            #????????°???False????????????int(i^2/2)?????????int(i)??????????????§False??????????????????
            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: import sys
 
def prime_calc(n):
    if n < 2:
        return False
    else:
        i = 2
        while n > i:
            if n % i == 0:
                return False
            else:
                i += 1
    return True
 
def prime(n):
    cnt = 0
    for i in range(0, n+1):
        ans = prime_calc(i)
        if ans is True:
            cnt = cnt + 1
 
    return cnt
 
def main():
    a = []
 
    for line in sys.stdin:
        a.append(int(line))
 
    for line in a:
        print(prime(line))
 
if __name__ == "__main__":
    main()

Python: #!/usr/bin/env python3
import itertools
import math
import sys

MAX = 999999


def sieve_of_eratosthenes(max):
    is_prime = [True] * (max + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(math.sqrt(max)) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * i, max + 1, i):
            is_prime[j] = False
    return filter(lambda x: is_prime[x], range(max + 1))


def main():
    p = list(sieve_of_eratosthenes(MAX))
    for l in sys.stdin:
        n = int(l)
        print(len(list(itertools.takewhile(lambda x: x <= n, p))))


if __name__ == '__main__':
    main()

Python: #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys

LIMIT = 1000000
is_prime = [True] * (LIMIT+1)
p = 2
while p**2 <= LIMIT:
    if is_prime[p]:
        for i in range(p*2, n+1, p):
            is_prime[i] = False
    p += 1

for line in sys.stdin.readlines():
    n = int(line.strip())
    if n <= 1:
        print(0)
        continue
    if n == 2:
        print(1)
        continue
    num_prime = 1
    for i in range(3, n+1):
        if is_prime[i]:
            num_prime += 1
    print(num_prime)

Python: # -*-coding:utf-8
#n??\???????´???°?????°

import fileinput
import math

def main():

    for line in fileinput.input():
        tokens = list(map(int, line.strip().split()))

        primeNumber = tokens[0]
        ans = 1
        for i in range(3, primeNumber+1, 2):
            flag = 0
            for j in range(3, int(math.sqrt(i))+1, 2):
                if(i%j == 0):
                    flag = 1
                    break

            if(flag == 0):
                ans += 1

        print(ans)

if __name__ == '__main__':
    main()

Python: import math
b=[]
b.append(1)
b.append(2)
count=1
s=0
while s<30:
    try:
        x=int(input())
        if x>b[count]:
            for i in range(b[count]+1,x+1):
                count1=0
                
                for j in range(2,int(math.sqrt(i))+1):
                    if i%j==0:
                        count1=1
                        break
                if count1==0:
                    count+=1
                    b.append(i)
            print(count)
        else:
            for i in range(count+1):
                if b[i]>x:
                    print(i-1)
                    break
                elif b[i]==x:
                    print(i)
                    break
        s+=1
    except EOFError:
        break

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: from math import sqrt
cash = {}
def isprime(n):
    if n in cash:
        return cash[n]
    if n == 1:
        cash[n] = 0
        return 0
    if n == 2:
        cash[n] = 1
        return 1
    if n % 2 == 0:
        cash[n] = 0
        return 0
    for i in range(2,int(sqrt(n)+1)):
        if n % i == 0:
            cash[n] = 0
            return 0
    cash[n] = 1
    return 1

from sys import stdin
cash2 = {}
for i in stdin:
    i = int(i)

    c = sum(isprime(n) for n in range(2,i+1))
    print(c)

Python: # ?´???°?????°?????¨?????????????????°??????

import sys

prim_no = {}

def is_prime(no):
    if no == 2:
        return True
    
    if no % 2 == 0:
        return False

    if prim_no.get(no) is not None:
        return prim_no.get(no)
    
    for i in range(3, no // 2):
        if no % i == 0:
            prim_no[no] = False
            return False

    prim_no[no] = True
    return True

while True:
    num = sys.stdin.readline()
    if num is None or num.strip() == '':
        break

    num = int(num.strip())
    cnt = 0
    for i in range(2, num + 1):
        if is_prime(i):
            cnt += 1

    print(cnt)

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

import sys
import os
import math



def Eratosthenes(n):
    lst = [i for i in range(2, n+1)]
    primes = []
    sqrt_n = n ** 0.5

    while True:
        first = lst.pop(0)
        if first < sqrt_n:
            primes.append(first)
            new_lst = []
            for v in lst:
                if v % first != 0:
                    new_lst.append(v)
            lst = new_lst
        else:
            # ??????
            return primes + [first] + lst

if __name__ == '__main__':
    inputs = sys.stdin.readlines()
    for s in inputs:
        n = int(s)
        lst = Eratosthenes(n)
        print(len(lst))