Go: package main

import "fmt"

func main() {
	const MAX = 1000000
	prime := make([]int, MAX, MAX)
	check := make([]int, MAX, MAX)
	count := make([]int, MAX, MAX)

	prime[0] = 1
	prime[1] = 1

	// prime init
	for i := 2; i < MAX; i++ {
		if check[i] == 1 {
			continue
		}

		if prime[i] == 0 {
			for j := i * 2; j < MAX; j += i {
				check[j] = 1
				prime[j] = 1
			}
		}
	}

	for i := 2; i < MAX; i++ {
		cnt := 0

		if prime[i] == 0 {
			cnt = 1
		}

		count[i] = count[i-1] + cnt
	}

	for {
		var input int
		inputCount, _ := fmt.Scanf("%d", &input)
		if inputCount != 1 {
			break
		}

		fmt.Println(count[input])
	}
}

Python: import sys

def prime(n):
	if n == 2: return True
	if n < 2 or n & 1 == 0: return False
	return pow(2, n-1, n) == 1

a = [prime(i) for i in range(1000000)]

for s in sys.stdin:
	i = int(s)
	print(a[:i+1].count(True))

Python: from math import sqrt
def pm(n):
    l = list(range(3,n+1)[0::2])
    p = 3
    i = 0
    p = l[i]
    m = sqrt(n)+1
    while p <= m:
        l = l[:i+1] + [n for n in l[i+1:] if n%p != 0]
        i += 1
        p = l[i]
    return len(l) + 1

from sys import stdin
for i in stdin:
    print(pm(int(i)))

Python: def make_prime():
	prime=[0 for i in range(10**6)]
	used=[0 for i in range(10**6)]
	for i in range(2,10**6):
		if used[i]==1:
			prime[i]=prime[i-1]
			continue
		prime[i]=prime[i-1]+1;
		for j in range(i,10**6,i):
			used[j]=1
	return prime

def main():
	prime=make_prime()
	while True:
		try: n=int(input())
		except EOFError: break
		print(prime[n])

if __name__=="__main__":
	main()

Python: import sys
import math

N = 1000000
primes = [1] * (N//2)
primes[0] = 0

for i in (x for x in range(3,int(math.sqrt(N)),2) if primes[x//2]):
    primes[(i*i)//2::i] = [0] * len(primes[(i*i)//2::i])

for i in sys.stdin:
    n = int(i)
    if n == 1:
        print(0)
    elif n == 2:
        print(1)
    else:
        print(sum(primes[0:(n+1)//2])+1)

Python: import sys

ary=[]
for i in sys.stdin:
    ary.append(int(i))

def isp(n):
    a = 1
    for i in range(2, int(n ** 0.5) + 1):
        if not n % i:
            a = 0
            break
    return a

for i in ary:
    s = 0
    for i in range(2, 12):
        if isp(i):
            s += 1
    print(s)

Python: # -*- coding: utf-8 -*-

import sys


def eratosthenes_sieve(n):
    table = [0]*(n + 1)
    prime_list = []
    
    for i in range(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i + i, n + 1, i):
                table[j] = 1
    return prime_list


def prime(n):
    return eratosthenes_sieve(n)

def main():
    inp = [int(n) for n in sys.stdin]
    for n in inp:
        n_pn = len(prime(n))
        print(n_pn)

if __name__ == '__main__':
    main()

Python: 
def isp(n):
    a = 1
    for i in range(2, (n + 1) // 2 + 2):
        if not n % i:
            a = 0
            break
    return a


num = int(input())
if num == 2:
    print(1)
elif num == 3:
    print(2)
else:
    s = 2
    for x in range(2, num + 1):
        if isp(x):
            s += 1
    print(s)

Python: n = 999999
c = [1 for i in range(n)]
c[0] = 0
i = 2
while i**2 <= n:
    j = i*2
    while j <= n:
        c[j - 1] = 0
        j += i
    i += 1

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

Python: 
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def sieve(n):
    p = [True for i in range(n + 1)]
    p[0] = p[1] = False
    end = int(n ** .5)
    for i in range(2, end + 1):
        if p[i]:
            for j in range(i * i, n + 1, i):
                p[j] = False
 
    return p
 
def primes_below(n):
    if n < 2: return 0
    c = 1
    for i in range(3, n + 1, 2):
        if p[i]: c += 1
 
    return c
 
p = sieve(1000000)
while 1:
    try:
        n = int(input())
    except EOFError:
        break
    else:
        print(primes_below(n))

Python: import sys


def isp(n):
    a = 1
    for i in range(2, (n + 1) // 2 + 2):
        if not n % i:
            a = 0
            break
    return a


ary = []
for i in sys.stdin:
    ary.append(int(i))

for i in ary:
    if i == 2:
        print(1)
    elif i == 3:
        print(2)
    else:
        s = 2
        for x in range(2, i + 1):
            if isp(x):
                s += 1
        print(s)

Python: #0009
a = []
l = [2]
while True:
    try:
        a.append(int(input()))
    except:
        break

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
    
z = primes(max(a))


for k in a:
    y = len([x for x in z if x <= k])
    print(y)

Python: import sys
def isPrime(i):
    if i<2:
        return False
    else:
        for j in range(2,i):
            if j*j>n:
                break
            elif i%j==0:
                return False
        return True

def countPrime(i):
    cnt=0
    for x in range(2,i+1):
        if isPrime(x) == True:
            print(x)
            cnt+=1
    return cnt

for line in sys.stdin:
    n=int(line)
    cnt=0
    for x in range(2,n+1):
        if isPrime(x)==True:
            cnt+=1
    print(cnt)

Python: import sys
def PrimNum(p):
    i = 0
    while True:
        if len(l) <= i: break
        if l[i] > p: break
        i+=1
    return i
def PrimeList(p) -> list:
    if p == 2: return 1
    elif p > 2:
        l = list(range(2, p+1))
        i = 0
        while pow(l[i], 2) <= p:
            # 2~pまでの数字の表を作って、2からpに向けて一つずつその倍数となる数を消していく。消されずに残っているものは素数である。
            # 入力の内の最大数のみを取り出して、この関数にかける。他の値はリストの中から
            l = [ l[j] for j in range(0, len(l)) if j <= i or l[j] % l[i] != 0] 
            i+=1
    return l
a = [int(line) for line in sys.stdin]
l = PrimeList(max(a)) # 最大値のみを渡す
for i in a: print(PrimNum(i))

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:
   if(ch == 26):
      exit()
   num = int(input())
   count_prime = 0
   for i in range(2,num+1):
       if(isprime(i) == 1):
           count_prime += 1
   print(count_prime)

Python: import sys

N = 1000000
lst = [1] * N
for i in range(3, int(N**0.5), 2):
    if lst[i]:
        lst[i*i::2*i] = [0] * len(lst[i*i::2*i])
lst = [2] + [i for i in range(3, N, 2) if lst[i]]
for i in sys.stdin:
    for j in range(len(lst)):
        if lst[j] > int(i):
            print(j)
            break

Python: import sys, math

class Eratos(object):
    def __init__(self, N):
        self.N = N
        self._primes = {i:True for i in range(2, N+1)}

    def filter(self):
        end = self.N
        if self.N > 5:
            end = math.ceil(self.N**0.5) + 1
        for n in range(2, end):
            if not self._primes[n]:
                continue
            for x in range(n*2, self.N+1, n):
                if x in self._primes:
                    self._primes[x] = False
    
    def primes(self, x):
        return [k for k,v in self._primes.items() if v == True and k <= x]

def run():
    e = Eratos(999999)
    e.filter()
    for _n in sys.stdin:
        N = int(_n)
        print(len(e.primes(N)))

if __name__ == '__main__':
    run()

Python: import sys

num_of_data = 0

while True:
    if num_of_data >= 30:
        break
    try: 
        n = int(input())
        if n >= 1 and n <= 999999:
            cnt = 0
            for i in range(1, n+1):
                flag = 0
                for j in range(1, i+1):
                    if i%j == 0:
                        flag += 1
                if flag == 2:
                    cnt += 1

            print(cnt)
            num_of_data += 1
    
    except EOFError:
        sys.exit()