Go: package main

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

func search(min, max int, channel chan int) {
	flag := false
	count := 0
	for i := min; i <= max; i++ { //1を除く入力値以下の数字
		for j := 2; j < i; j++ {
			if i%j == 0 {
				flag = true
				break
			}
		}
		if !flag {
			count++
		} else {
			flag = false
		}
	}
	channel <- count
	return
}

func main() {
	count := 0
	channel := make(chan int)
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		for i := 2; i < num; i += 10 {
			if i+10 < num {
				count++
				go search(i, i+10, channel)
			} else {
				count++
				go search(i, num, channel)
			}
		}
		var ans int
		for i := 0; i < count; i++ {
			ans += <-channel
		}

		fmt.Println(ans)
	}
}

Python: from math import sqrt
def prime(n):
    if n == 2:
        return True
    elif n < 2 or n % 2 == 0:
        return False
    else:
        i = 3
        while i <= sqrt(n):
            if n % i == 0:
                return False
            i += 2
    return True

while True:
    try:
        n = int(input())
        if n < 2:
            c = 0
        else:
            c = 1
        for i in range(3,n+1,2):
            if prime(i):
                c += 1

        print(c)

    except:
        exit()

Python: MAX = 1000000

# 素数の表
prime_map = [True] * MAX
prime_map[0] = False
prime_map[1] = False

# n以下の素数の表
prime_num_map = [0] * MAX

for i in range(2, MAX):
    if prime_map[i]:
        prime_num_map[i] = prime_num_map[i-1] + 1
        index = 2
        n = i*index
        while n < MAX:
            prime_map[n] = False
            index += 1
            n = i*index
    else:
        prime_num_map[i] = prime_num_map[i-1]

while True:
    try:
        n = int(input())
        print(prime_num_map[n])
    except:
        exit(0)

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 no_debug_input(array):
    for line in sys.stdin:
        array.append(int(line))

def debug_input(array):
    parser = argparse.ArgumentParser()
    parser.add_argument("filename", help="The filename to be processed")
    args = parser.parse_args()

    if args.filename:
        with open(args.filename) as f:
            for line in f:
                a = int(line.rstrip())
                array.append(a)

def main():
    l = []

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

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

if __name__ == "__main__":
    main()

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(3,int(sqrt(n)+1))[0::2]:
        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: def Eratosthenes(n):
	N = [1 for i in range(0,n+1)]
	i = 3
	while i*i<=n:
		if N[i]:
			j = i*i
			while j<=n:
				N[j] = 0
				j += i*2
		i += 2
	return N

N = Eratosthenes(999999)
while True:
	try:
		n = int(input())
	except EOFError:
		break
	cnt = 0
	if n>=2:
		cnt = 1
	for i in range(3, n+1, 2):
		cnt += N[i]
	print(cnt)

Python: import math as m

while(True):
    try:
        n = input()
    except EOFError:
        break
    
    an = 0
    n = int(n)
    

    an = n
    a = [True for i in range(n+1)]
    
    j=2
    while True:
        if j > m.sqrt(n):
            break
        
        if a[j]==False:
            j = j+1
            continue
        
        k=2
        while k*j <= n:
            if a[k*j]==True:
                #print(k*j)
                a[k*j]=False
                an = an-1
            
            k=k+1
        
        j=j+1

    if n==2:
        an = 2

    if n==3:
        an = 3

    print(an-1)

Python: p = [0, 0, 1, 1, 0, 1]
while True:
    try:
        n = int(input())
        if len(p) < n+1:
            i = len(p)
            while i < n+1:
                j = 2
                flag = True
                while j <= i**0.5:
                    if i % j == 0:
                        p.append(0)
                        flag = False
                        break
                    j += 1
                if flag == True:
                    p.append(1)
                i += 1
        print(sum(p[0:n+1]))
    except:
        break

Python: import bisect
num = 1000000
L = [True] * (num+1)
L[0] = False
L[1] = False
for i in range( 2, int(num**0.5)+ 2 ):
    if not L[i]:
        continue
    for j in range(i*2, num+1, i):
        L[j] = False

p = [ x for x in range(num+1) if L[x] ]

while True:
    try:
        n = int(input())
        k = bisect.bisect_left(p,n+1)
        print(k)
    except:
        break

Python: from math import *

search_list = []
prime_list = []
target = 0

def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break
if __name__ == '__main__':
    array = list(get_input())
    for i in range(len(array)):
        #??\????????¨?????????????????????????????§?´???°????????°?????¢?´¢??????
        for j in range(2,int(array[i])+1):
            #??¢?´¢??????????????????
            search_list.append(j)
        #print(sqrt(int(array[i])))
        while True:
            if target > sqrt(int(array[i])):
                prime_list = prime_list + search_list
                break
            prime_list.append(search_list[0])
            target = search_list[0]
            search_list.pop(0)
            k = 1
            while target*k<=search_list[-1]:
                #print(target * k)
                if target*k in search_list:
                    search_list.remove(target*k)
                k += 1
            #print(search_list)
        #print(str(array[i]) + "??\???????´???°???" + str(prime_list) + "??????????????°???" + str(len(prime_list)))
        print(len(prime_list))
        target = 0
        prime_list.clear()
        search_list.clear()

Python: import sys
import math

N = []
ns = sys.stdin.readlines()
for n in ns:
    N.append(int(n))
ml = max(N)
P = [2]
for x in range(3, ml+1):
    flag = True
    for d in [p for p in P if (p < int(math.sqrt(x))+1)]:
        flag = flag and (x % d != 0)
    if flag == True:
        P = P + [x]
for m in N:
    print(len([p for p in P if p<=m]))

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

Python: import sys
m=500000;a=[1]*m
for i in range(3,999,2):
 if a[i//2]:a[i*i//2::i]=[0]*((m-1-i*i//2)//i+1)
for e in map(int,sys.stdin):print([e-1,sum(a[:(e+1)//2])][e>3])

Python: if __name__ == '__main__':
    while True:
        n = int(input())
        is_prime = [True for i in range(n + 1)]
        is_prime[0] = False
        is_prime[1] = False

        p = 0

        for i in range(2, n + 1):
            if is_prime[i]:
                p += 1
                for j in range(i * 2, n + 1, i):
                    is_prime[j] = False

        print(p)