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
import math

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

def is_prime(no):
    if no == 2:
        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():
    while True:
        num = sys.stdin.readline()
        if num is None or num.strip() == '':
            break

        num = int(num.strip())
        if num == 1:
            cnt = 0
        else:
            cnt = 0
            for i in range(3, num + 1, 2):
                if is_prime(i):
                    cnt += 1
            cnt += 1

        print(cnt)

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

Python: def prime(n, p):
  cnt = 0
  for i in range(n+1):
    if(p[i]):
      cnt += 1
  return cnt
  
p = [True for i in range(1000001)]
p[0] = False
p[1] = False
for i in range(2, 500001):
  for j in range(2, 1000000//i + 1):
    p[i * j] = False

while True:
  try:
    n = int(input())
  except EOFError:
    break
  print(prime(n, p))

Python: #coding:utf-8
import time
import math
import numpy as np

def flatten(L):
    if isinstance(L, list):
        if L == []:
            return []
        else:
            return flatten(L[0]) + flatten(L[1:])
    else:
        return [L]

def Eratos(data):

    p_list = [] # ????????????
    tmp = []
    num = int(math.sqrt(len(data)))+1
    for i in data:
        i=data[0]
        if i>num:
            break
        else:
            p_list.append(i)
            for j in data:
                if j%i == 0:
                    data.remove(j)
        
    p_list.append(data)
    return p_list

x = int(input())

r_list = list(range(2,(x+1)))
ans = []
ans = Eratos(r_list)

print(len(flatten(ans)))

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: def prime_count(N):
    primes = [2, 3]
    count = 1
    for n in range(5, N+1, 2):
        isprime = True
        for i in range(1, len(primes)):
            if primes[i] ** 2 > n:
                break
            if n % primes[i] == 0:
                isprime = False
                break
        if isprime:
            count += 1
    return count

while True:
    try:
        print(prime_count(int(input())))
    except:
        break

Python: import sys
from math import sqrt

for line in sys.stdin:
    n = int(line.strip())
    L, pn, tmp = int(sqrt(n)), [], [i for i in range(2, n+1)]
    while tmp[0] < L+1:
        v = tmp.pop(0)
        pn.append(v)
        tmp = list(filter(lambda x: x%v!=0, tmp))
    for t in tmp: pn.append(t)
    print(len(pn))

Python: def main():
	import sys

	MAX = 1000000

	table = [True]*1000000
	table[0] = table[1] = False

	primes = []
	counted = 0

	for i in range(MAX):
		if table[i]:
			primes.append(i)
			for j in range(2*i, MAX, i):
				table[j] = False

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

		cnt = 0
		for prime in primes:
			if prime > n:
				break
			else:
				cnt += 1
		print(cnt)


if __name__ == '__main__':
	main()

Python: def sieve(n=10**6):
  p=[1]*(n+1)
  for i in range(2,n+1):
    if p[i]:
      for j in range(2*i,n+1,i):p[j]=0
  p[0],p[1]=0,0
  return p
while True:
  try:print(sum(sieve(int(input()))))
  except:break

Python: import math
import sys

def E(d):

    p_list = [] 
    p=0
    tmp = []
    l = len(d)
    num = int(math.sqrt(len(d)))+1
    for i in d:
        i=d[0]
        if i>num:
            break
        else:
            # p_list.append(i)
            p=p+1
            for j in d:
                if j%i == 0:
                    d.remove(j)
                    l = l-1
        
    # print(len(p_list)+len(d))
    print(p+l)

for line in sys.stdin:
    x= [i for i in range(2,(int(line)+1))]
    E(x)

Python: import sys


xx = 500000
f = [0, 1] * xx

i = 3
while i * i <= 2 * xx:
    if f[i] == 1:
        j = i * i
        while j <= 2 * xx:
            f[j] = 0
            j += i + i
    i += 2

f.pop(0)
f.pop(1)

for n in sys.stdin:
    i = int(n)
    if i < 2:
        print(0)
    else:
        print(sum(f[:i - 1]))

Python: # PrimeNumber

from itertools import product
import math


def nOfPrime(m):
    return m * 2


if __name__ == "__main__":
    while True:
        try:
            n = int(input())
            prm = 1
            nlist = []
            nlist2 = []
            plist = []

            for i in range(2, n + 1):
                nlist.append(i)  # [2,3,4,5,6,...,n]

            while True:
                #print(nlist, " ", math.sqrt(n))
                if nlist[0] > math.sqrt(n):  # 終了条件
                    #plist.append(map(int,nlist))
                    plist.extend(nlist)
                    break;
                else:
                    plist.append(nlist[0])

                    #i = 0
                    for j in nlist:
                        if j % nlist[0] != 0:
                            #nlist.pop(i)
                            #nlist.remove(j)
                            nlist2.append(j)
                        #i += 1
                    nlist = nlist2
                    nlist2 = []
            #print("fin: {}".format(plist))
            print(len(plist))

        except EOFError:
            break  # escape from while loop

pass
#

Python: try:
    while True:
        n = int(input())
        datasets = list(range(2, n+1))
        answers = set([])
        while datasets:
            i = datasets[0]
            datasets = filter(lambda data: data%i != 0, datasets)
            answers.add(i)
        print(len(answers))
except:
    pass

Python: import math, sys


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:
        try:
            n = int(input())
        except:
            break
        v = erastos(n)
        primes = [i for i, b in enumerate(v) if b == True]
        print(len(primes))

Python: primes = [0, 0] + [1] * 999999
for i in range(2, 1000):
    if primes[i]:
        for j in range(i*i, 1000000, i):
            primes[j] = 0

answer = [0] * 1000000
for i in range(2, 1000000):
    answer[i] += primes[i] + answer[i-1]

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

Python: LIMIT = 999999

prime = [0, 1] + [0 if i % 2 == 0 else 1 for i in range(3, LIMIT + 1)]

for i in range(3, LIMIT + 1):
    if prime[i - 1]:
        for j in range(i ** 2, len(prime), i):
            prime[j - 1] = 0

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