Go: package main
import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	//"math"
)

var sc = bufio.NewScanner(os.Stdin)

func main(){
	for sc.Scan(){
		n := nextInt()
		fmt.Println(calc(n))
	}
}

func calc(n int)int{
	// エラトステネスで数え上げる
	// 最初から999999まで用意しておいて入力のたびO(1)で出すのとどっちが速いのかはわからん
	eratos := make([]bool, n+1)
	c := 0
	for i:=2; i<len(eratos); i++{
		if eratos[i] == false{
			c++
			for j:=i*i; j<len(eratos); j+=i{
				eratos[j]=true
			}
		}
	}
	return c
}

func next()string{
	return sc.Text()
}

func nextInt()int{
	a, _ := strconv.Atoi(next())
	return a
}

Python: import math
import sys

def prime_calc(n):
    rootN = int(n**0.5)
    prime = [2]
    data = [i + 1 for i in range(2,n,2)]
    while True:
        p = data[0]
        if rootN <= p:
            return len(prime + data)
        prime.append(p)
        data = [e for e in data if e % p != 0]

def main():
    l = []

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

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

if __name__ == "__main__":
    main()

Python: o_list=[]
while True:
	try:
		n=int(input())
		I_list=[i for i in range(2,n+1)]
		prime_list=[]
		for i in I_list:
			k=I_list[0]
			prime_list.append(k)
			for j in I_list:
				if j%k==0:
					I_list.remove(j)

		K=set(I_list) | set(prime_list)
		K=list(K)
		K=sorted(K)
		o_list.append(len(K))
	except:
		for i in o_list:
			print(i)
		break

Python: import math

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=[]
for k in range(1):
    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, sys

def erastos(n):
    n += 1
    try:
        v = [0 if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else 1 for i in range(n)]
        v[0] = v[1] = 0
        v[2] = v[3] = v[5] = 1
    except IndexError:
        return [0, 0, 1, 1, 0, 1][:n]
    sqrt = math.sqrt(n)
    for serial in range(3, n, 2):
        if serial > sqrt:
            return v
        for s in range(serial ** 2, n, serial):
            v[s] = 0
if __name__ == '__main__':
    while True:
        try:
            n = int(input())
            v = erastos(n)
            primes = [i for i, b in enumerate(v) if b == True]
            print(len(primes))
        except:
            break

Python: import sys

prime = [2,3,5,7,11,13,17,19,23,29,31]

shieve1 = [1]*1001
for i in prime:
    itr = i-1
    while(itr<1000):
        shieve1[itr] = 0
        itr += i

for i in range(32,1000):
    if shieve1[i]:
        prime.append(i+1)

shieve2 = [1]*(10**6+1)

for i in prime:
    itr = i-1
    while(itr<10**6):
        shieve2[itr] = 0
        itr += i

for i in range(1001,10**6+1):
    if shieve2[i]:
        prime.append(i+1)

for line in sys.stdin:
    n = int(line)
    cont = 0
    for i in prime:
        if i<=n:
            cont += 1
        else:
            break
    print(cont)

Python: prime_num=[2]
while(True):
	try:
		date=int(input())
	except:
		break
	if(date==1):
		print(1)
		continue
	prime_num=[2]
	for i in range(3,date+1):
		flag=True
		j=0
		while(True):
			if(i**0.5<prime_num[j]):
				break
			if(i%prime_num[j]==0):
				flag=False
				break
			j+=1
		if(flag):
			prime_num.append(i)
	print(len(prime_num))

Python: import math

def IsPrimer(num):
	if num == 1:
		isprimer = False
	else:
		isprimer = True
		for divisor in range(2, int(math.sqrt(num)) + 1):
			if num % divisor == 0:
				isprimer = False
				break
	return isprimer

while True:
	try:
		num = eval(input())
		count = 0
		for i in range(2, num + 1):
			if IsPrimer(i):
				count += 1
		print(count)
	except EOFError:
		break

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

Python: from sys import stdin
a = [True]*1000000
for i in range(2,1000000):
    if a[i]:
        for j in range(i+i, 1000000)[::i]:
            a[j] = False

b = [None]*1000000
b[0] = b[1] = 0
for i in range(2,1000000):
    if a[i]:
        b[i] = b[i-1] + 1
    else:
        b[i] = b[i-1]

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

Python: def isPrime(num):
    if num == 1:
        return False
    elif num == 2:
        return True
    elif num % 2 == 0:
        return False
    else:
        for i in range(3, int(num ** 0.5) + 1, 2):
            if num % i == 0:
                return False

        return True


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

    count = 0
    for i in range(1, n + 1):
        count += 1 if isPrime(i) else 0

    print(count)

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

Python: prime=[2]
for i in range(3,100,2):
    primeq=True
    for p in prime:
        if i%p==0:
            primeq=False
            break
        if i<p*p:break
    if primeq:prime.append(i)
while True:
    try:
        n=int(input())
        ans=0
        for p in prime:
            if p>n:break
            ans+=1
        print(ans)
    except:break

Python: MAX = 1000000
SQRT = 1000     # sqrt(MAX)
 
prime = [0] * MAX
 
def sieve():
    for i in range(3, MAX, 2):
        prime[i] = 1
    for i in range(3, SQRT, 2):
        if prime[i] == 1:
            for j in range(i*i, MAX, i):
                prime[j] = 0
 
sieve()
cnt = [0] * (MAX+1)
cnt[2] = f = 1
for i in range(3, MAX, 2):
    if prime[i]:
        f += 1;
    cnt[i] = cnt[i+1] = f
     
while True:
    try:
        print(cnt[int(input())])
    except EOFError:
        break

Python: import sys
def fact(n):
    ret = [1]
    if n%2==0:
        ret.append(2)
        return ret
    for i in range(3,int(n**0.5)+1,2):
        if n%i==0:
            ret.append(i)
            return ret
    return ret
def isPrime(n):
    if n<=1:
        return False
    if n==2:
        return True
    if fact(n)==[1]:
        return True
    else:
        return False
lines = sys.stdin.readlines()
for line in lines:
    inp = int(line)
    s=0
    for i in range(2,inp+1):
        if isPrime(i):
            s+=1
    print (s)

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

def sieve(n):
    p = 0
    primes = []
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if(is_prime[i]):
            primes.append(i)
            p += 1
            for j in range(i*2,n,i):#iごとに増える
                is_prime[j] = False
    return p

if(__name__ == "__main__"):
    while(True):
        try:
            n = int(input())
        except:
            break
        print(sieve(n))

Python: from math import sqrt,floor
from sys import stdin

def cntPrime(n):
    mx = sqrt(n) + 1
    if n % 2 == 0:
      l = [0, 1] + [1, 0] * (int(n/2) - 1)
    else:
      l = [0, 1] + [1, 0] * (int(n/2) - 1) + [1]
    c = 3
    while c < mx:
        for k in range(c, floor(n/c) + 1, 1):
            l[c * k -1] = 0
        c = l[:c].index(1) + c
        while c % 2 == 0 or (c > 5 and c % 5 == 0): 
            c = l[:c].index(1) + c
    return sum(l)
for n in stdin:
    n = int(n)
    print(cntPrime(n))

Python: import sys
for line in sys.stdin:
    n = int(line)
    count = 0
    for i in range(2,n+1):
        k = 2
        flag = True
        while k**2 <= i:
            if i%k == 0:
                flag = False
                break
            k += 1
        if flag:
            count += 1
    print (count)