Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var resultArr [100]int
	var inputCount, primeCount, input int
	for {
		fmt.Scanf("%d", &input)
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		resultArr[inputCount] = primeCount
		if inputCount == 30 {
			break
		}
		primeCount = 0
		inputCount++
	}
	for _, v := range resultArr {
		fmt.Printf("%d\n", v)
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2:
		return true
	case num < 2 || num%2 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

Python: import sys

MAX = 999999
L = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]

def is_prime(n):
  if n == 2:return True
  if n % 2 == 0:return False
  for i in range(3,int(n**0.5)+1,2):
    if n % i == 0:return False
  return True

def is_prime_2(n):
  a = int(n ** 0.5)
  for i in L:
    if i > a:return True
    if n % i == 0:return False
  return True

def prime_count(n):
  result = 0
  if n >= 2:result+=1
  for i in range(3,n+1,2):
    if is_prime_2(i):result+=1
  return result

def prime_list(n):
  result = []
  if n >= 2:result.append(2)
  for i in range(3,n+1,2):
    if is_prime(i):result.append(i)
  return result

L2 = prime_list(MAX)

def prime_count_2(n):
  for i,v in enumerate(n):
    if n > v:return i
  return len(L2)

for n in sys.stdin:
  print(prime_count_2(int(n)))

Python: import math


def sieve_of_erastosthenes(num):
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):
        
        if serial >= sqrt:
            return input_list

        for s in range(serial ** 2, num, serial): 
            input_list[s] = False


if __name__ == '__main__':
    while True:
        try:
            n = int(input())
        except:
            break

        input_list = sieve_of_erastosthenes(n)
        
        print(sum(input_list))

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(3, floor(n/c) + 1):
            l[c * k -1] = 0
        c = l[:c].index(1) + c
    return sum(l)
for n in stdin:
    n = int(n)
    print(cntPrime(n))

Python: import sys
a=[0,0]+[1]*10**6
for i in range(999):
 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 math
import sys

def E(d):

    p_list = [] 
    tmp = []
    num = int(math.sqrt(len(d)))+1
    for i in d:
        i=d[0]
        if i>num:
            break
        else:
            p_list.append(i)
            for j in d:
                if j%i == 0:
                    d.remove(j)
        
    print(len(p_list)+len(d))

lists = []
for line in sys.stdin:
    x= [i for i in range(2,(int(line)+1))]
    E(x)

Python: import sys
import math

lines = str(sys.stdin.read()).strip().split("\n")

for line in lines:
    line = int(line)
    pList = []
    sList = list(reversed(list(range(3, line + 1))[::2]))
    while sList[-1] < int(math.ceil(math.sqrt(line))) + 1:
        pList.append(sList.pop())
        for p in pList:
            sList = list(filter(lambda i: i % p != 0, sList))
    pList.extend(sList)
    pList.append(2)
    print(len(pList))

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: numbers=[]
for i in range(1000000):
	numbers.append(True)
numbers[0]=False
numbers[1]=False

idx=1
multiple=1

while True:
	idx+=1
	multiple=idx
	if idx>1000000**(1/2):
		break
	while True:
		if 999999<idx*multiple:
			break
		numbers[idx*multiple]=False
		multiple+=1
#print(numbers)


def count(n):#関数「count」を定義
	cnt=0
	for i in range(n+1):
		if numbers[i]==True:
			cnt+=1
	print(cnt)


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

Python: import sys
for i in sys.stdin:
    n = int(i)
    arr = [i for i in range(0,n+1)]
for i in range(2, len(arr)):
    if arr[i] != 0:
        j = 2
        while i*j <= n:
            if arr[i*j] != 0:
                arr[i*j] = 0
            j += 1
primNum = 0
for i in arr:   
    if i > 1:
        primNum += 1
print(primNum)

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: while True:
	try:
		n=int(input())
		a=[True]*(n+1)
		a[0]=a[1]=False
		for i in range(2,int(n**0.5)+1):
			if a[i]:
				for j in range(i**2,n,i):
					a[j]=False
		print(a.count(True))
	except:
		break

Python: import sys

LIMIT = 10000000

isPrime = [True] * LIMIT

isPrime[0] = isPrime[1] = False

for i in range(2, int(LIMIT ** 0.5)+1):
  print(i)
  if isPrime[i]:
    for j in range(2 * i, LIMIT, i):
      isPrime[j] = False

countPrime = [0] * LIMIT

for i in range(1, LIMIT):
  countPrime[i] = countPrime[i-1] + isPrime[i]

for line in sys.stdin.readlines():
  print(countPrime[int(line)])

Python: import sys
lines = sys.stdin.readlines()
for line in lines:
    a = int(line)
    b = [False, False]
    for i in range(a-1):
        b.append(True)
    for i in range(a):
        if(b[i]):
            k = i
            while(k <= a-i):
                k += i
                b[k] = False
    #print(b)
    cnt = 0
    for i in b:
        if(i):
            cnt += 1
    print(cnt)