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: def isprime(num):
   i = 2
   count = 0
   while i< num:
       if num % i == 0:
           count += 1
       i += 1
   if count == 0:
       return 1
   else:
       return 0
ch = 0
while ch != 26:
   num = int(input())
   count_prime = 0
   for i in range(2,num+1):
       if(isprime(i) == 1):
           count_prime += 1
   print(count_prime)

Python: import math
import sys

def get_primes(n):
    search = list(range(2, n+1))
    primes = []
    while True:
        primes.append(search[0])
        for i,x in enumerate(search):
            if x % primes[-1] == 0:
                del search[i]
        if search[0] >= math.sqrt(n):
            primes.extend(search)
            return primes

for line in sys.stdin.readlines():
    n = int(line)
    print(len(get_primes(n)))

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)[1::2]) + 1
    print(c)

Python: #!/usr/bin/env python
# -*- coding:utf-8 -*-
#from __future__ import print_function
import time
import sys
import io
import re
import math
start = time.clock()

def prime(n):
    l=[True for _ in range(n+1)]
    i=2
    while i**2<=n:
        if l[i]:
            j=i+i
            while j<=n:
                l[j]=False
                j+=i
        i+=1
    return l
#    lis=[i for i in range(n+1) if l[i] and i>=2]

for n in sys.stdin:
    print (prime(int(n))).count(True)-2

Python: from math import sqrt
def f(x):
    lst  = [i for i in range(x + 1)]
    flag = [1 for i in range(x + 1)]
    flag[0] = flag[1] = 0
    for i in lst:
        if flag[i] == 0:
            continue
        else:
            for j in range(i*2, x + 1, i):
                flag[j] = 0
    return flag.count(1)

a = []
while True:
    try:
        a.append(int(input()))
    except EOFError:
        break

for x in a:
    print(f(x))

Python: numlist=[0,1]+[0]*999998
for i in range(3,1000000,2):
    numlist[i]=1
for i in range(3,1000,2):
    if numlist[i]==1:
        for j in range(i*i,1000000,i):
            numlist[j]=0

cnt=[0]*1000001
count=0
for i in range(1,1000000,2):
    if numlist[i]:
        count+=1
    cnt[i]=cnt[i+1]=count

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

Python: max_num = 1000000
cnt = 0
p = [1] * max_num
p[0] = p[1] = 0
for i in xrange(2, int(max_num ** 0.5) + 1):
    if p[i]:
        p[i * i::i] = [0] * len(p[i * i::i])
        cnt += 1
    p[i] = cnt

while True:
    try: print(p[input()])
    except: break

Python: import sys
from array import array

N = 1000000
primes = array('I',[1]) * (N//2)
primes[0] = 0

for i in range(3,int(N**0.5),2):
    if primes[i//2]:
        primes[(i*i)//2::i] = array('I',[0]) * len(primes[(i*i)//2::i])

for i in sys.stdin:
    n = int(i)
    if n < 4:
        print(n-1)
    else:
        print(sum(primes[:(n+1)//2])+1)

Python: import sys

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

for e in sys.stdin:
    n = int(e)
    print(len(primes(n)))

Python: import argparser

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 main():
    l = []
    
    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())
                l.append(a)


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

if __name__ == "__main__":
    main()

Python: import math

def prime_judge(n):
    if n==1:
        return False
    elif n==2:
        return True
    elif n%2==0:
        return False
    else:
        sqrt_num=math.ceil(math.sqrt(n))+1
        for i in range(3,sqrt_num, 2):
            if n%i==0:
                return False
        return True

def prime_count(n):
    count=0
    for i in range(1,n+1):
        if prime_judge(i):
            count+=1
    print(count)

while 1:
    try:
        prime_count(int(input()))        
    except EOFError:
        break

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

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

Python: LIMIT = 10000000
 
isPrime = [True for _ in range(LIMIT)]

isPrime[0] = isPrime[1] = False
 
for i in range(2, int(LIMIT ** 0.5)+1):
  if isPrime[i]:
    for j in range(i * i, LIMIT, i):
      isPrime[j] = False
 
try:
    while True:
        n = int(input())
        count = 1 if isPrime[2] else 0
        for i in range(3, n+1, 2):
            if isPrime[i]:
                count += 1
        print(count)
except EOFError:
  pass

Python: import sys
m=166666;s=[1]*m;t=[1]*m
for i in range(m):
 for j in range(2):
  if (s[i],t[i])[j]:
   k=6*i+[5,7][j];n=[i+k,k-i-2]
   s[n[j]::k]=[0]*len(s[n[j]::k])
   t[n[1-j]::k]=[0]*len(t[n[1-j]::k])
for e in map(int,sys.stdin):
 print([e-1,sum(s[:(e+1)//6])+sum(t[:(e-1)//6])+2][e>3])

Python: def primes(n):
    ass = []
    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
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass
    
if __name__ == '__main__':

    while True:
        try:
            n = int(input())

            ans = primes(n)
            print(len(ans))
            
        except EOFError:
            break

Python: import sys
n = [int(line) for line in sys.stdin]

prime = [0, 0] + [1] * (max(n) - 1)

for i in range(len(prime)):
    if prime[i]:
        for j in range(2 * i, len(prime), i):
            prime[j] = 0

for i in range(1, len(prime)):
    prime[i] += prime[i - 1]

for ni in n:
    print(prime[ni])