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: #!/usr/bin/env python3

"""Enumerates primes in an interval.

Verification: [0009](https://onlinejudge.u-aizu.ac.jp/status/users/hamukichi/submissions/1/0009/judge/4571021/Python3)
"""


import math
import sys


def segment_sieve(begin, end):
    """Enumerates the prime numbers in [`begin`, `end`).

    Returns (as a tuple):

    - `is_prime`: a list of bool values.
      If an integer `i` is a prime number, then `is_prime[i - begin]` is True.
      Otherwise `is_prime[i -begin]` is False.
    - `primes`: a list of prime numbers in [`begin`, `end`).
    """

    assert 1 < begin <= end
    sqrt_end = math.ceil(math.sqrt(end))
    is_prime_small = [True for i in range(sqrt_end)]
    is_prime_small[0] = False
    is_prime_small[1] = False
    is_prime = [True for i in range(end - begin)]
    for i in range(2, sqrt_end):
        if is_prime_small[i]:
            for j in range(2 * i, sqrt_end, i):
                is_prime_small[j] = False
            for k in range(max(2, (begin + i - 1) // i) * i, end, i):
                is_prime[k - begin] = False
    primes = [i for i, cond in enumerate(is_prime, begin) if cond]
    return is_prime, primes


def main():
    ns = [int(n) for n in sys.stdin.readlines()]
    max_n = max(ns)
    begin = 2
    is_prime, _ = segment_sieve(begin, max_n + 1)
    for n in ns:
        print(sum(is_prime[:n + 1 - begin]))


if __name__ == '__main__':
    main()

Python: import sys
for i in sys.stdin:
    n = int(i)
    if n <= 3:
        print(max(0, n - 1))
        continue
    a = [2, 3]
    for k in range(5, n + 1, 2):
        for e in a:
            if k % e == 0:
                break
        else:
            a.append(k)
    print(len(a))

Python: #79 素数の数

import math

while(1):
    try:
        n = int(input())
    except:
        break
    
    m = int(math.sqrt(n))
    keys = [n // i for i in range(1, m+1)] #1からm+1の間のみn//iを行う
    keys += range(keys[-1]-1, 0, -1) #range(始まりの数値,最後の数値,増加量)
    h = {i: i-1 for i in keys}
    
    for i in range(2, m+1):
        if h [i] > h[i-1]:
            hp = h[i-1]
            i2 = i*i
            for j in keys:
                if j < i2:
                    break
                h[j] -= h[j // i] - hp
    print(h[n])

Python: import sys
x = 1000000
xx = 500000
f = [1, 0] * xx
f[0] = 0
f[1] = 1  # [02305070...]12345
i = 3
while i < x:
    if f[i] == 1:
        j = i
        y = x // i + 1
        while j < y:
            f[j] = 0
            j += i + i
    i += 2

for n in sys.stdin:
    i = int(n)
    if i < 2:
        print(0)
    else:
        print(sum(f[:i - 1]))

Python: import sys
import math
from bisect import bisect_right
n = 1000000
a = set(range(3, n, 2))
diff = a.difference_update
for i in range(3, int(math.sqrt(n)), 2):
    if i in a:
        diff(range(i*2, n+1, i))

primes = [2] + list(a)
for l in map(int, sys.stdin.readlines()):
    print(bisect_right(primes, l))

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 math
def isPrime(x):
	if x == 2:
		return True
	elif x < 2 or x % 2 == 0:
		return False
	else:
		i = 3
		while i <= math.sqrt(x):
			if x % i == 0:
				return False
			i += 2
		return True

import sys
dataset = sys.stdin.readlines()
for n in dataset:
	n = int(n)
	counter = 0
	for i in range(n+1):
		if isPrime(i):
			counter += 1
	print(counter)

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

def atkin(limit):
    sqrt_limit = int(math.sqrt(limit))
    is_prime = [False] * (limit + 1)
    primes = []
    if limit == 1:
        return primes
    if limit >= 2:
        is_prime[2] = True
    if limit >= 3:
        is_prime[3] = True
    for x in range(1, sqrt_limit):
        for y in range(1, sqrt_limit):
            k = 4*x**2 + y**2
            if k <= limit and (k%12 == 1 or k%12 == 5):
                is_prime[k] ^= True
            k = 3*x**2 + y**2
            if k <= limit and k%12 == 7:
                is_prime[k] ^= True
            k = 3*x**2 - y**2
            if x > y and k <= limit and k%12 == 11:
                is_prime[k] ^= True

    r = 5
    while r**2 < limit:
        if is_prime[r]:
            i = r**2
            while i < limit:
                is_prime[i] = False
                i += r**2
        r += 1

    for i in range(limit + 1):
        if is_prime[i]:
            primes.append(i)

    return primes

for line in sys.stdin.readlines():
    n = int(line.strip())
    primes = atkin(n)
    #print(primes)
    print(len(primes))

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: def check_prime(goal):
    true_or_false=False
    for i in range(2,goal):
        if goal%i==0:
             true_or_false=True
    if true_or_false==False:
        return True
    else:
        return False

anss=[]
while True:
    try:
        num=int(input())
        num_of_prime=0
        for i in range(2,num+1):
           if check_prime(i):
               num_of_prime+=1
        anss.append(num_of_prime)
    except:
        break

for ans in anss:
    print(ans)

Python: import math
import sys

def prime_calc(n):
    if n < 2:
        return False
    elif n==2 or n==3 or n==5 or n==7:
        return True
    else:
        rootN = math.floor(math.sqrt(n))
        i = 11
        while rootN > i:
            if n % i == 0:
                return False
            else:
                i += 2

    return True

def prime(n):
    cnt = 0
    for i in range(2, n+1):
        ans = prime_calc(i)
        if ans is True:
            cnt = cnt + 1

    return cnt

def main():
    l = []

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

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

if __name__ == "__main__":
    main()