Go: package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	num := make([]bool, 1000000)

	for sc.Scan() {
		var nmpr int

		n, _ := strconv.Atoi(sc.Text())

		lmt := int(math.Sqrt(float64(n)))

		for i := 2; i <= lmt; i++ {
			for j := 2; i*j <= n; j++ {
				if !num[i*j] {
					num[i*j] = true
				}
			}
		}

		for t := 2; t <= n; t++ {
			if !num[t] {
				nmpr++
			}
		}

		fmt.Println(nmpr)
	}

}

Python: PN = [i for i in range(1000000)]
#print(PN[0:20])
i = 2
while True:
    if i >= len(PN):
        break
    j = i * 2
    while True:
        if j >= len(PN):
            break
        PN[j] = 0
        j += i
    while True:
        i += 1
        if i >= len(PN):
            break
        if PN[i] != 0:
            break
PN[1] = 0
#print(PN[0:20])
cntPN = []
for i in range(1000000):
    if i == 0:
        cntPN.append(0)
    elif PN[i] == 0:
        cntPN.append(cntPN[i - 1])
    else:
        cntPN.append(cntPN[i - 1] + 1)

#print(cntPN[0:20])

import sys

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

for i in a:
    print(cntPN[i])

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

Python: import math
def main():
    for _ in range(30):
        number = int(input())
        p = 0
        for num in range(2, number+1):
            a = int(math.sqrt(num))
            c = 0
            for k in range(2, a+1):
                if num % k == 0:
                    c = 1
                    break
            if c == 0:
                p += 1
        print(p)
    return None


if __name__ == '__main__':
    main()

Python: import sys

def primeTable(n):
    list = [True for _ in range(n+1)]
    i = 2
    while i * i <= n:
        if list[i]:
            j = i+i
            while j<= n:
                list[j] = False
                j += i
        i += 1

    table = [i for i in range(n+1) if list[i] and i >= 2]
    return table

lines = sys.stdin.readlines()
primeList = primeTable(999999)

for line in lines:
    inp = int(line)
    primes = list(filter(lambda n:n>=2 and n<=inp, primeList))
    num = len(primes)
    print (num)

Python: import math
MAX = 1000000
A = [1]*MAX

for i in range(2,int(math.sqrt(MAX))+1):
    if A[i]==1:
        for j in range(2*i,MAX,i):
            A[j]=0
A[0]=0
A[1]=0
for i in range(1,MAX):
    A[i] += A[i-1]

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

Python: import math

def check_prime(goal):
    true_or_false=False
    for i in range(2,int(math.sqrt(goal))+1):
        if goal%i==0:
             true_or_false=True
    if true_or_false==False:
        return True
    else:
        return False
anss=[]
while True:
    try:
        num=int(input())
        num_of_prime=0
        for i in range(2,num+1):
           if check_prime(i):
               num_of_prime+=1
        anss.append(num_of_prime)
    except:
        break

for ans in anss:
    print(ans)

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

    # print([i for i, b in enumerate(input_list) if b == True])
    return sum(input_list)


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

        print(sieve_of_erastosthenes(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

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

        
print(count)

Python: a=int(input())
X=[i for i in range(2,a+1)]
while True:
  X=[i for i in X if i % X[0] !=0 ]
  if X == Y:
    break
  Y=X[:]
 
print(len(X))

Python: t = 0
while t == 0:	
	total = 0
	try:
		n = int(input())
	except:
		break
	else:
                print(total)

Python: import sys

def primes(n):
    ps = []
    table = [True] * n
    table[0] = False
    for i in range(n):
        if table[i]:
            for j in range(2 * (i + 1) - 1, n, i + 1):
                table[j] = False
    for i in range(n):
        if table[i]:
            ps.append(i + 1)
    return ps

for line in sys.stdin:
    n = int(line)
    print(len(primes(n)))

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

Python: 
prime=[True]*1000000
np=[0]*1000000
for i in range(2,1000):
    if prime[i]:
        for j in range(i*2,1000000,i):
            prime[j]=False
    np[i]=np[i-1]+prime[i]
    
while True:
    try:
        n=int(input())
    except:
        break
    print(np[n])

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

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

Python: import math


def erastos(n):
    n += 1
    try:
        v = [0 if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else 1 for i in range(n)]
        v[0] = v[1] = 0
        v[2] = v[3] = v[5] = 1
    except IndexError:
        return [0, 0, 1, 1, 0, 1][:n]
    sqrt = math.sqrt(n)
    for serial in range(3, n, 2):
        if serial > sqrt:
            return v
        for s in range(serial ** 2, n, serial):
            v[s] = 0

if __name__ == '__main__':
    while True:
        n = int(input())
        v = erastos(n)
        primes = [i for i, b in enumerate(v) if b == True]
        print(len(primes))

Python: maxv = 0
primes = [0]*1000000
jk = True
def isPrime(x):
    if x == 2:
        return True
    if x < 2 or x % 2 == 0:
        return False
    i, root_x = 3, int(pow(x, 0.5))
    while i <= root_x:
        if x % i == 0:
            return False
        i += 2
    return True

while True:
    try:
        n = int(input())
    except:
        break
    tmp = max(n, maxv)
    if jk:
        for i in range(2, n+1):
            if isPrime(i): primes[i] = 1
        jk = False
        maxv = max(n, maxv)
    else:
        if maxv != tmp:
            maxv = tmp
            for i in range(n, maxv+1):
                if isPrime(i): primes[i] = 1
    print(sum([1 for i in range(n+1) if primes[i] == 1]))

Python: from math import sqrt
def prime(n):
    if n == 2:
        return True
    elif n < 2 or n % 2 == 0:
        return False
    else:
        i = 3
        while i <= sqrt(n):
            if n % i == 0:
                return False
            i += 2
    return True

while True:
    try:
        n = int(input())
        if n < 2:
            c = 0
        else:
            c = 1
        for i in range(3,n+1,2):
            if prime(i):
                c += 1

        print(c)

    except:
        exit()

Python: MAX = 1000000

# 素数の表
prime_map = [True] * MAX
prime_map[0] = False
prime_map[1] = False

# n以下の素数の表
prime_num_map = [0] * MAX

for i in range(2, MAX):
    if prime_map[i]:
        prime_num_map[i] = prime_num_map[i-1] + 1
        index = 2
        n = i*index
        while n < MAX:
            prime_map[n] = False
            index += 1
            n = i*index
    else:
        prime_num_map[i] = prime_num_map[i-1]

while True:
    try:
        n = int(input())
        print(prime_num_map[n])
    except:
        exit(0)