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: import sys
import math as mas

def sieve(n):
	p=[True for i in range(n+1)]
	p[0]=p[1]=False
	end=int(n**0.5)
	for i in range(2,end+1):
		if p[i]:
			for j in range(i*i,n+1,i):
				p[j]=False
	return p
	
sosu=sieve(1000010)
for i in sys.stdin:
	print(sum(sosu[t] for t in range(int(i)+1)))

#	a,b=map(int,i.split())
#	print(gcd(a,b),lcm(a,b))

Python: import sys


def prime(x):
    for i in p_list:
        if x % i == 0:
            return 0
    return 1


if __name__ == "__main__":
    a = 10000
    i = 2
    p_list = []
    while i < a:
        if prime(i):
            p_list.append(i)
        i += 1
    print(p_list)

    for i in sys.stdin:
        n = int(i)
        while 1:
            if n not in p_list:
                n -= 1
            else:
                print(p_list.index(n) + 1)

Python: import sys
#from me.io import dup_file_stdin

N=1000000
primes = [1]*N
primes[0:2]=[0,0,1]

for i in range(2,N):
    if primes[i]==1:
        j=i+i
        while j<=N:
            primes[j]=0
            j+=i

#@dup_file_stdin
def solve():
    for query in map(int,sys.stdin):
        print(sum(primes[2:query+1]))
solve()

Python: from math import *
search_list = []
search_list_ref = []
prime_list = []
prime_list_ref = []
target1,target2,num = 0,0,2
i,j,k = 0,0,0
flag = 0
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break
if __name__ == "__main__":
    array = list(get_input())
    #print("/*------------------------------------*/")
    for i in range(len(array)):
        #print(str(array[i]) + "?????????????´???°????±??????????")
    #??\????????¨?????????????????????????????§?´???°????????°?????¢?´¢??????
        #?????????sqrt(int(array[i]))?????§????????§?´???°??????????????????
        ref_target = int(sqrt(int(array[i])))
        search_list_ref.append(2)
        search_list_ref.append(ref_target)
        while target1 < ref_target:
            if search_list_ref == []:
                break
            prime_list_ref.append(search_list_ref[0])
            target1 = search_list_ref[0]
            search_list_ref.remove(target1)
            if target1 > ref_target:
                break
            num = target1
            if target1 == 2:
                for num in range(2,ref_target):
                    if (num % target1 != 0):
                        search_list_ref.append(num)
                if ref_target != 3:
                        search_list_ref.remove(ref_target)
            else:
                for j in search_list_ref:
                    if j % target1 == 0:
                        search_list_ref.remove(j)

        prime_list_ref = prime_list_ref + search_list_ref
        search_list.append(2)
        search_list.append(int(array[i]))

        #?????????????????¬??\?±????????????°?????????????´???°????±??????????
        while target2 < sqrt(int(array[i])):
            prime_list.append(search_list[0])
            target2 = search_list[0]
            search_list.remove(target2)
            if target2 > sqrt(int(array[i])):
                break
            num = target2
            if target2 == 2:
                for num in range(2,int(array[i])):
                    for k in prime_list_ref:
                        if num % k != 0:
                            flag = 1
                        else:
                            flag = 0
                            break
                    if flag == 1:
                        search_list.append(num)
                search_list.remove(int(array[i]))
                prime_list_ref.pop(0)
                search_list[1:1] = prime_list_ref
            elif target2 not in prime_list_ref:
                for j in search_list:
                    if j % target2 == 0:
                        search_list.remove(j)
            else:
                pass
        prime_list = prime_list + search_list
        print(str(len(prime_list)))
        del search_list_ref[:]
        del prime_list_ref[:]
        del search_list[:]
        del prime_list[:]
        target1 = 0
        target2 = 0
        #print("/*------------------------------------*/")

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

def prime(n):
    a = [0] * (n + 1)
    a[0] = 1
    a[1] = 1
    i = 2
    while n // i >= i:
        if a[i] != 0:
            i += 1
            continue
        j = 2 * i
        while j <= n:
            a[j] = 1
            j += i
        i += 1
    return [i for i, ai in enumerate(a) if ai == 0]

for i in sys.stdin:
    print(len(prime(int(i))))

Python: isPrime = [True] * 1000000
prime = [0, 0]
def calcPrime():
    isPrime[0] = isPrime[1] = False
    count = 0
    for i in range(2, len(isPrime)):
        if(isPrime[i]):
            count += 1
            prime.append(count)
            for j in range(2 * i, len(isPrime), i):
                isPrime[j] = False
        else:
            prime.append(count)

calcPrime()
while(True):
    try:
        n = input()
        print(prime[n])
    except Exception:
        break

Python: import sys

values = []
for line in sys.stdin:
    values.append(int(line))

for val in values:
    prime = 0
    i = 2
    while i <= val:
        j = 2
        while j <= i:
            if i % j == 0:
                if j == i:
                    prime += 1
                else:
                    break
            j += 1
        i += 1
    print(prime)

Python: import math
def pri(n):
    if n < 2:
        return False
    elif n == 2:
        return True
    elif n % 2 == 0:
        return False

    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            return False
        i += 2
    return True

l=[i for i in range(110000)if pri(i) ]

while True:
    n = int(input())
    if n == 0: break
    print(sum(l[:n]))

Python: import math

def AtkinSieve (limit):
    results = [2,3,5]
    sieve = [False]*(limit+1)
    factor = int(math.sqrt(limit))+1
    for i in range(1,factor):
        for j in range(1, factor):
            n = 4*i**2+j**2
            if (n <= limit) and (n % 12 == 1 or n % 12 == 5):
                sieve[n] = not sieve[n]
            n = 3*i**2+j**2
            if (n <= limit) and (n % 12 == 7):
                sieve[n] = not sieve[n]
            if i>j:
                n = 3*i**2-j**2
                if (n <= limit) and (n % 12 == 11):
                    sieve[n] = not sieve[n]
    for index in range(5,factor):
        if sieve[index]:
            for jndex in range(index**2, limit, index**2):
                sieve[jndex] = False
    for index in range(7,limit):
        if sieve[index]:
            results.append(index)
    return results

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

Python: N = 1000000
p = [1] * N

(p[0],p[1]) = (0,0)
for i in range(N):
  if (p[i]):
    for j in range (i*2,N,i):
      p[j] = 0

for i in range (1,N):
  p[i] += p[i-1]

while True:
  try:
     n = int(input())
  except EOFError:
     break
  print (p[n])