Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var resultArr [40]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
#from me.io import dup_file_stdin

N=1000000
primes = [1]*N
primes[0:2]=[0,0,1]

for i in range(2,N):
    if primes[i]==1:
        j=i+i
        while j<=N:
            primes[j]=0
            j+=i

#@dup_file_stdin
def solve():
    for query in map(int,sys.stdin):
        print(sum(primes[2:query+1]))
solve()

Python: from math import *
search_list = []
search_list_ref = []
prime_list = []
prime_list_ref = []
target1,target2,num = 0,0,2
i,j,k = 0,0,0
flag = 0
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break
if __name__ == "__main__":
    array = list(get_input())
    #print("/*------------------------------------*/")
    for i in range(len(array)):
        #print(str(array[i]) + "?????????????´???°????±??????????")
    #??\????????¨?????????????????????????????§?´???°????????°?????¢?´¢??????
        #?????????sqrt(int(array[i]))?????§????????§?´???°??????????????????
        ref_target = int(sqrt(int(array[i])))
        search_list_ref.append(2)
        search_list_ref.append(ref_target)
        while target1 < ref_target:
            if search_list_ref == []:
                break
            prime_list_ref.append(search_list_ref[0])
            target1 = search_list_ref[0]
            search_list_ref.remove(target1)
            if target1 > ref_target:
                break
            num = target1
            if target1 == 2:
                for num in range(2,ref_target):
                    if (num % target1 != 0):
                        search_list_ref.append(num)
                if ref_target != 3:
                        search_list_ref.remove(ref_target)
            else:
                for j in search_list_ref:
                    if j % target1 == 0:
                        search_list_ref.remove(j)

        prime_list_ref = prime_list_ref + search_list_ref
        search_list.append(2)
        search_list.append(int(array[i]))

        #?????????????????¬??\?±????????????°?????????????´???°????±??????????
        while target2 < sqrt(int(array[i])):
            prime_list.append(search_list[0])
            target2 = search_list[0]
            search_list.remove(target2)
            if target2 > sqrt(int(array[i])):
                break
            num = target2
            if target2 == 2:
                for num in range(2,int(array[i])):
                    for k in prime_list_ref:
                        if num % k != 0:
                            flag = 1
                        else:
                            flag = 0
                            break
                    if flag == 1:
                        search_list.append(num)
                search_list.remove(int(array[i]))
                prime_list_ref.pop(0)
                search_list[1:1] = prime_list_ref
            elif target2 not in prime_list_ref:
                for j in search_list:
                    if j % target2 == 0:
                        search_list.remove(j)
            else:
                pass
        prime_list = prime_list + search_list
        print(str(len(prime_list)))
        del search_list_ref[:]
        del prime_list_ref[:]
        del search_list[:]
        del prime_list[:]
        target1 = 0
        target2 = 0
        #print("/*------------------------------------*/")

Python: import sys
a=[0,0]+[1]*10**6
for i in range(999):
 if a[i]:a[i*2::i]=[0 for j in a[i*2::i]]
for e in sys.stdin:print(sum(a[:int(e)+1]))

Python: import sys

def prime(n):
    a = [0] * (n + 1)
    a[0] = 1
    a[1] = 1
    i = 2
    while n // i >= i:
        if a[i] != 0:
            i += 1
            continue
        j = 2 * i
        while j <= n:
            a[j] = 1
            j += i
        i += 1
    return [i for i, ai in enumerate(a) if ai == 0]

for i in sys.stdin:
    print(len(prime(int(i))))

Python: isPrime = [True] * 1000000
prime = [0, 0]
def calcPrime():
    isPrime[0] = isPrime[1] = False
    count = 0
    for i in range(2, len(isPrime)):
        if(isPrime[i]):
            count += 1
            prime.append(count)
            for j in range(2 * i, len(isPrime), i):
                isPrime[j] = False
        else:
            prime.append(count)

calcPrime()
while(True):
    try:
        n = input()
        print(prime[n])
    except Exception:
        break

Python: import sys

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

for val in values:
    prime = 0
    i = 2
    while i <= val:
        j = 2
        while j <= i:
            if i % j == 0:
                if j == i:
                    prime += 1
                else:
                    break
            j += 1
        i += 1
    print(prime)

Python: import math
def pri(n):
    if n < 2:
        return False
    elif n == 2:
        return True
    elif n % 2 == 0:
        return False

    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            return False
        i += 2
    return True

l=[i for i in range(110000)if pri(i) ]

while True:
    n = int(input())
    if n == 0: break
    print(sum(l[:n]))

Python: import math

def AtkinSieve (limit):
    results = [2,3,5]
    sieve = [False]*(limit+1)
    factor = int(math.sqrt(limit))+1
    for i in range(1,factor):
        for j in range(1, factor):
            n = 4*i**2+j**2
            if (n <= limit) and (n % 12 == 1 or n % 12 == 5):
                sieve[n] = not sieve[n]
            n = 3*i**2+j**2
            if (n <= limit) and (n % 12 == 7):
                sieve[n] = not sieve[n]
            if i>j:
                n = 3*i**2-j**2
                if (n <= limit) and (n % 12 == 11):
                    sieve[n] = not sieve[n]
    for index in range(5,factor):
        if sieve[index]:
            for jndex in range(index**2, limit, index**2):
                sieve[jndex] = False
    for index in range(7,limit):
        if sieve[index]:
            results.append(index)
    return results

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

Python: N = 1000000
p = [1] * N

(p[0],p[1]) = (0,0)
for i in range(N):
  if (p[i]):
    for j in range (i*2,N,i):
      p[j] = 0

for i in range (1,N):
  p[i] += p[i-1]

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

Python: def eratosthenes(n):
  multiples = set()
  for i in range(2, n+1):
    if i not in multiples:
      yield i
      multiples.update(range(i*i, n+1, i))

while True:
  try:
    print(len(list(eratosthenes(int(input())))))
  except:
    break

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

Python: import sys

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

max_val = max(array)
prime_list = [1] * max_val
prime_list[0] = 0
prime_list[1] = 0

i = 2
while i < max_val:
    for j in range(i * 2, max_val, i):
        prime_list[j] = 0
    i = i + 1
    while i < max_val and prime_list[i] == 0:
        i = i + 1

for val in array:
    count = sum(prime_list[:val + 1])
    print(count)