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: def sieve(n):
    p=0
    prime=[0]*n
    is_prime=[0]*(n+1)
    for i in xrange(n+1):
        is_prime[i]=True
    is_prime[0]=is_prime[1]=False
    for i in xrange(2,n+1):
        if is_prime[i]:
            p+=1
            prime[p]=i
            for j in xrange(2*i,n+1,i):
                is_prime[j]=False
    return p
while 1:
    try:
        n=input()
        print(sieve(n))
    except:
        break

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]*len(a[i*i//2::i])
p=[]
for i in range(m*2):p.append(i-1 if i<4 else p[i-1]+[0,a[i//2]][i%2])
for e in sys.stdin:print(p[int(e)])

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

Python: while True:
  try:
    a = int(input())
    primes = [1] * (a+1)
    for i in range(2, int(a**0.5)+1):
      if primes[i] == 1:
        for j in range(i*i, a+1, i):
          primes[j] = 0
    print(sum(primes)-2) 
  except EOFError:
    break

Python: import sys
from math import floor, sqrt
from bisect import bisect_right

primes = [2]

def isPrime(v):
    threshold = floor(sqrt(v))
    for p in primes:
        if p > threshold:
            break
        if v % p == 0:
            return False
    return True

for v in range(3, 1000000, 2):
    if isPrime(v):
        primes.append(v)

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

for v in values:
    print(bisect_right(primes, v))

Python: 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

    for serial in range(3, int(num ** 0.5) + 1, 2):
        
        if input_list[serial] is True:
            
            for s in range(serial ** 2, num, serial): 
                input_list[s] = False

    return sum(input_list)

print(sieve_of_erastosthenes(999999))

Python: def sieve(n=10**6):
  p=[1]*(n+1)
  for i in range(2,n+1):
    if p[i]:
      for j in range(2*i,n+1,i):p[j]=0
  p[0],p[1]=0,0
  return p
while True:
  try:print(sum(sieve(int(input()))))
  except:break

Python: from sys import stdin

def prime(n):
    Prime = [i for i in range(n + 1)]
    for i in range(2, n + 1):
        for j in range(2, int(n / i) + 1):
            Prime[i * j] = 0
    Prime[0], Prime[1] = 0, 0
    ans = [i for i in Prime if not (i == 0)]
    return len(ans)

Ans = []
for line in stdin:
    n = int(line)
    Ans.append(prime(n))
for po in Ans:
    print(po)

Python: from math import sqrt
def prime(n):
    if n == 2:
        return True
    elif n < 2 or n % 2 == 0:
        return False
    else:
        i = 1
        while p_list[i] <= sqrt(n):
            if n % p_list[i] == 0:
                return False
            i += 1
    return True
def p_count(n):
    c = 0
    for p in p_list:
        if(p > n):
            break
        c += 1
    return c

p_list = [2,3]
while True:
    try:
        n = int(input())
        for i in range(p_list[-1]+2,n+1,2):
            if (prime(i)):
                p_list.append(i)
        print(p_count(n))
    except:
        exit()

Python: m=10*6;a=[0]+[1]*m
for i in range(999):
 if a[i]:a[i*2+1::i+1]=[0 for e in range(len(li[i*2+1::i+1]))]
for e in sys.stdin:print(len([i for i in li[:int(e)]if i]))

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))
    # p_list.append(d)
    # return p_list

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

Python: while True:
    try:
        Num = 1
        n = int(input())
        for i in range(2,n+1):
            for j in range(2,i):
                if i % j == 0:
                    break
                if j == i-1:
                    Num +=1
        print(Num)           
    except EOFError:
        break

Python: import sys
def prime(n):
  i = 2
  if n == 1:
    l = []
  else:
    l = [2]
  while i < n:
    i += 1
    for j in l:
      if i % j == 0:
        break
    else:
      l.append(i)
  return len(l)
for line in sys.stdin.readlines():
  n = int(line)
  print(prime(n))

Python: import sys
s=[2]
for i in range(3,999999):
	for j in range(2,i-1):
		if not i%j:break
	else:
		s.append(i)
		# print(i)
for n in sys.stdin:
	n=int(n)
	cnt=0
	for i,iv in enumerate(s):
		if iv>n:
			print(i)
			break
	else:
		print(i+1)

Python: def solve(n):
	A=[0 for i in range(n+1)]
	for i in range(2,n+1):
		cnt=0
		for j in range(1,i+1):
			if i%j==0:
				cnt+=1
		if cnt==2:#1??¨????????°??????
			A[i]=1
	cnt=0
	for i in A:
		if i==1:
			cnt+=1
	return cnt 

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

Python: import numpy
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break
def primesfrom3to(n):
    sieve = numpy.ones(int(n/2), dtype=numpy.bool)
    for i in range(3,int(n**0.5)+1,2):
        if sieve[int(i/2)]:
            sieve[int(i*i/2)::int(i)] = False
    return 2*numpy.nonzero(sieve)[0][1::]+1
if __name__ == "__main__":
    array = list(get_input())
    for i in range(int(len(array))):
        primeList = list(primesfrom3to(int(array[i])))
        primeList.insert(0,2)
        #print(primeList)
        print(len(primeList))

Python: DP = [0,1,2]

while True:
    try:
        n = int(input())
        if len(DP) < n:
            for i in range(len(DP) + 1,n+1):
                YN = 0
                for j in range(2,i - 1):
                    if i % j == 0:
                        DP.append(DP[len(DP) - 1])
                        YN = 1
                        break
                    elif j ** 2 > i:
                        DP.append(DP[len(DP) - 1] + 1)
                        break

        print(DP[n - 1])
    except EOFError:
        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(2 * i, LIMIT, i):
      isPrime[j] = False

countPrime = [0 for _ in range(LIMIT)]

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

try:
  while True:
    n = int(input())
    print(countPrime[n])
except EOFError:
  pass