Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var primeCount, input int
	for {
		fmt.Scanf("%d", &input)
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		fmt.Printf("%d\n", primeCount)
		primeCount = 0
	}
}

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

Python: # ?´???°?????°?????¨?????????????????°??????

import sys
import math

prim_no = {2: True}                    # ????????°????´???°??§??????????????????????????????

def is_prime(no):
    if no == 2 or no == 1:
        return True
    
    if no % 2 == 0:
        return False

    if prim_no.get(no) is not None:
        return prim_no.get(no)

    max_check = int(math.sqrt(no))
    for i in range(3, max_check+1, 2):
        if no % i == 0:
            prim_no[no] = False
            return False

    prim_no[no] = True
    return True

def main():
    prim_vals = {}                         # ????????°?????§????´???°????????°
    num_data = []                          # ?????????????????????
    
    while True:
        num = sys.stdin.readline()
        if num is None or num.strip() == '':
            break

        num = int(num.strip())
        num_data.append(num)

    sorted_num_data = sorted(num_data)
    prim_num = {}
    
    for num in sorted_num_data:
        if prim_vals.get(num) is not None:
            cnt = prim_vals.get(num)
        else:
            if num == 1:
                cnt = 0
            else:
                cnt = 0

                if num % 2 == 0:
                    start_num = num -1
                else:
                    start_num = num
                    
                for i in range(start_num, 0, -2):
                    if prim_vals.get(i) is not None:
                        cnt += prim_vals.get(i)
                        break
                    
                    if is_prime(i):
                        cnt += 1
                        
                prim_vals[num] = cnt # ????????°?????§????´???°????????°????????????
        prim_num[num] = cnt

    for num in num_data:
        print(prim_num[num])

if __name__ == '__main__':
    main()
    #print(prim_no)

Python: import sys
while True:
    try:
        s=int(input())+1
    except:
        sys.exit()
    if s<2:
        print(0)
    else:
        list=[True]*s
        list[0]=False
        list[1]=False
        i=2
        while i**2<=s-1:
            j=i*2
            while j<=s-1:
                list[j]=False
                j+=i
            i+=1
        print(list.count(True))

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: nums = []
while True:
    try:
        n = int(input())
    except EOFError:
        break
    nums.append(n)

M = max(nums)
primes = []
temp = [i for i in range(2,M+1)]
n = 2
while n*n <= M:
    primes.append(n)
    for i in temp:
        if i%n == 0:
            temp.remove(i)
    n=temp[0]

primes.extend(temp)
for i in nums:
    f = True
    for j,n in enumerate(primes):
        if n > i:
            print(j)
            f = False
            break
    if f:
        print(len(primes))

Python: import sys
results = {}
def fact(n):
    if n in results:
        return results[n]
    ret = [1]
    if n%2==0:
        ret.append(2)
        results[n]=ret
        return ret
    for i in range(3,int(n**0.5)+1,2):
        if n%i==0:
            ret.append(i)
            results[n]=ret
            return ret
    results[n]=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)