Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var resultArr [31]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 math
def kosu(n):
    l=[]
    sosu = [True] * (n + 1)
    sosu[0]= False
    sosu[1]= False
    for i in range(2,math.floor(math.sqrt(n))+1):
        if not sosu[i]:
            continue
        for j in range(i*2,n+1,i):
            sosu[j] = False
    for i in range(len(sosu)):
        if sosu[i]:
            l.append(i)
    return(l)
    
while True:
    try:
        n = int(input())
    except EOFError:
        break
    print(len(kosu(n)))

Python: limit = int(input(""))
arr = [2,3,5,7]
def PrimeNumber(arr,number):
    for i in arr:
        if (number%i==0):
            return False
    return True

for i in range(2,limit+1):
    if(PrimeNumber(arr,i)):
        arr.append(i)

        
count = 0
for i in arr:
    if (i>limit):
        break
    else:
        count += 1
    
print(count)
print()

Python: while True:
    try:
        r = int(input())

        alist = []

        for x in range(2, r+1):
            if x != 2 and x != 3 and x != 5:
                if x % 2 != 0 and x % 3 != 0 and x % 5 != 0:
                    alist.append(x)
            else:
                alist.append(x)

        print(len(alist))
    except EOFError:
        break

Python: import sys
for line in sys.stdin:
    n = int(line)
    arr = [i for i in range(0,n+1)]
    k = 2
    while k**2 <= n:
        for i in range(len(arr)):
            if arr[i]%k == 0 and arr[i] != 2:
                arr[i] = 0
        print(k, arr)
        k += 1
    count = 0
    for i in range(len(arr)):
        if arr[i] != 0 and arr[i] != 1:
            count += 1
    print(count)

Python: import sys

for input in sys.stdin:
    prime_num = 0
    for i in range(int(input)):
        y = i+1
        x = y / 2
        r = 2
        while r <= x:
            if y % r == 0:
                break
            r += 1
        else:
            prime_num += 1
    print(prime_num-1)

Python: import sys
array = []
for i in sys.stdin:
  array.append(int(i))
m=max(array)
prime = [1]*(m+1)
prime[0] = prime[1] = 0
for i in range(2,int(m**0.5)+1):
  if prime[i] == 1:
    for j in range(i*i, m+1, i):
      prime [j] = 0
for i in range(len(array)):
  print(sum(prime[:array[i] + 1]))

Python: limit = int(input(""))
arr = [2,3,5,7]
def PrimeNumber(arr,number):
    for i in arr:
        if (number%i==0):
            return False
    return True

for i in range(2,limit+1):
    if(PrimeNumber(arr,i)):
        arr.append(i)

        
count = 0
for i in arr:
    if (i>limit):
        break
    else:
        count += 1
    
print(count)
print()

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

Python: import sys
import math

MAXNUM=1000000
SQRT=math.sqrt(MAXNUM)

def eratosthenes():
    l = [1]*MAXNUM
    l[0:2]=[0]*2
    l[4:MAXNUM:2] = [0]*len(l[4:MAXNUM:2])

    for i in range(3,1000,2):
        l[i*i:MAXNUM:i*2] = [0]*len(l[i*i:MAXNUM:i*2])

    return l

primes = eratosthenes()
for i in sys.stdin:
    n = int(i)
    print(sum(primes[0:n+1]))

Python: import math
b=[]
b.append(1)
b.append(2)
count=1
s=0
while s<30:
    try:
        x=int(input())
        if x>b[count]:
            for i in range(b[count]+1,x+1):
                count1=0
                
                for j in range(2,int(math.sqrt(i))+1):
                    if i%j==0:
                        count1=1
                        break
                if count1==0:
                    count+=1
                    b.append(i)
            print(count)
            print(b)
        else:
            for i in range(count+1):
                if b[i]>x:
                    print(i-1)
                    break
                elif b[i]==x:
                    print(i)
                    break
        s+=1
    except EOFError:
        break

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[0]*len(a[i*2::i])]
for e in sys.stdin:print(sum(a[:int(e)+1]))

Python: MAX=1000000
B=[]
def P(MAX,B):

    A=[i for i in range(2,MAX+1)]
    lim=MAX**(1/2)
    while True:
        p=A[0]
        if p>lim:
            B+=A
            return B
        else:
            B.append(p)
            A=[i for i in A if i%p!=0]
            
P(MAX,B)
while True:
    try:
        n=int(input())
        if n==1:
            print(0)
        elif n>=max(B):
            print(len(B))
        else:
            for i in range(n+1):
                if B[i]==n:
                    print(i+1)
                    break
                if B[i]>n:
                    print(i)
                    break

    except:
        break

Python: import bisect
primes = [0, 0] + [1]*999999
for i in range(2, 1001):
    if primes[i]:
        for j in range(i*i, 1000001, i):
            primes[j] = 0

primes = [i for i, v in enumerate(primes) if v]
while True:
    try:
        n = int(input())
    except:
        break
    print(bisect.bisect(primes, n))

Python: # coding: utf-8
# Your code here!

MAX = 1000000
#エラトステネスの篩を用いて素数リストを予め作成する
s = [1] * MAX
## まずは全ての数が素数か不明ということにしておく
## s[2]以降をfor文で1に変換するより、s[0]s[1]を0とする方が繰り返しを使わずに済む
s[0] = 0
s[1] = 0

start = 2
while True:
    ## はじめにpmbを0で初期化しておかないと、pmb==0という条件に入ることはない
    pmb = 0
    for i in range(start, MAX):
        if s[i] == 1: #素数か否か不明な数の中で最小値を探す
            pmb = i
            break #見つかったらループを抜ける
    #print("リストsの中身", s)
   
    if pmb == 0:
        break #素数が見つからなかった
   
    #篩にかける
    for i in range(pmb ** 2, MAX, pmb):
        s[i] = 0  #素数でない要素を０にする

    start += 1

    #素数一覧をを表示
   #  for i in range(2, MAX):
   #     if s[i] == 1:
   #        print(i)

while True:
    try:
        n = int(input())
        
        c = 0
        for i in range(2, n + 1):
            if s[i] == 1:
                c += 1
        print(c)

    except EOFError:
        break
    ## tryできたときに行いたい処理はtryのインデント内に書く
      #  c = 0
      #  for i in range(2, n + 1):
      #       if s[i] == 1:
      #           c += 1
      #  print(c)

Python: def kqpurge(num):
    k=0
    while num%2==0:
        num=num/2
        k+=1
    return k,int(num)

def miller_l(num):
    k,q=kqpurge(num-1)
    tnum=0
    if num==1:return False
    if num in [2,3,5,7]:return True
    for i in [2,3,5,7]:
        for e in range(k+1):
            if e==0:
                if i**q%num==1:
                    tnum+=1
                    break
                elif i**q%num==num-1:
                    tnum+=1
                    break
            else:
                temp=i**((2**e)*q)
                if temp%num==(num-1):
                    tnum=tnum+1
                    break
                elif temp%num==1:
                    break
    if tnum==4:
        return True
    else:
        return False
        
while True:
    try:n=int(input())
    except:break
    count=0
    for i in range(2,n+1):
        if miller_l(i):
            count+=1
    print(count)

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)