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 math
def isPrime(x):
	if x == 2:
		return True
	elif x < 2 or x % 2 == 0:
		return False
	else:
		i = 3
		while i <= math.sqrt(x):
			if x % i == 0:
				return False
			i += 2
		return True

import sys
dataset = sys.stdin.readlines()
for n in dataset:
	n = int(n)
	counter = 0
	for i in range(n+1):
		if isPrime(i):
			counter += 1
	print(counter)

Python: #!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
import sys

def atkin(limit):
    sqrt_limit = int(math.sqrt(limit))
    is_prime = [False] * (limit + 1)
    primes = []
    if limit == 1:
        return primes
    if limit >= 2:
        is_prime[2] = True
    if limit >= 3:
        is_prime[3] = True
    for x in range(1, sqrt_limit):
        for y in range(1, sqrt_limit):
            k = 4*x**2 + y**2
            if k <= limit and (k%12 == 1 or k%12 == 5):
                is_prime[k] ^= True
            k = 3*x**2 + y**2
            if k <= limit and k%12 == 7:
                is_prime[k] ^= True
            k = 3*x**2 - y**2
            if x > y and k <= limit and k%12 == 11:
                is_prime[k] ^= True

    r = 5
    while r**2 < limit:
        if is_prime[r]:
            i = r**2
            while i < limit:
                is_prime[i] = False
                i += r**2
        r += 1

    for i in range(limit + 1):
        if is_prime[i]:
            primes.append(i)

    return primes

for line in sys.stdin.readlines():
    n = int(line.strip())
    primes = atkin(n)
    #print(primes)
    print(len(primes))

Python: from math import *

search_list = []
prime_list = []
target = 0

def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break
if __name__ == '__main__':
    array = list(get_input())
    for i in range(len(array)):
        #??\????????¨?????????????????????????????§?´???°????????°?????¢?´¢??????
        for j in range(2,int(array[i])+1):
            #??¢?´¢??????????????????
            search_list.append(j)
        #print(sqrt(int(array[i])))
        while True:
            if target > sqrt(int(array[i])):
                prime_list = prime_list + search_list
                break
            prime_list.append(search_list[0])
            target = search_list[0]
            search_list.pop(0)
            k = 1
            while target*k<=search_list[-1]:
                #print(target * k)
                if target*k in search_list:
                    search_list.remove(target*k)
                k += 1
            #print(search_list)
        #print(str(array[i]) + "??\???????´???°???" + str(prime_list) + "??????????????°???" + str(len(prime_list)))
        print(len(prime_list))
        target = 0
        prime_list.clear()
        search_list.clear()

Python: def check_prime(goal):
    true_or_false=False
    for i in range(2,goal):
        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: import math
import sys

def prime_calc(n):
    if n < 2:
        return False
    elif n==2 or n==3 or n==5 or n==7:
        return True
    else:
        rootN = math.floor(math.sqrt(n))
        i = 11
        while rootN > i:
            if n % i == 0:
                return False
            else:
                i += 2

    return True

def prime(n):
    cnt = 0
    for i in range(2, n+1):
        ans = prime_calc(i)
        if ans is True:
            cnt = cnt + 1

    return cnt

def main():
    l = []

    for line in sys.stdin:
        l.append(int(line))

    for line in l:
        print(prime(line))

if __name__ == "__main__":
    main()

Python: import math


def sieve_of_erastosthenes(num):
    if 2 >= num:
        return 1
        
    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
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):
        
        if serial >= sqrt:
            return input_list

        for s in range(serial ** 2, num, serial): 
            input_list[s] = False


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

        input_list = sieve_of_erastosthenes(n)

        print(sum(input_list))

Python: 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: prime=[2]
for i in range(3,1000000,2):
    primeq=True
    for p in prime:
        if i%p==0:
            primeq=False
            break
        if i<p*p:break
    if primeq:prime.append(i)
while True:
    try:
        n=int(input())
        ans=0
        for p in prime:
            if p>n:break
            ans+=1
        print(ans)
    except:break

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

# n??\???????´???°?????°???????????¢??°
def prime(n):
    l = range(0,n+1)
    i,k = 0,2
    result = 1

    if n >= 3:
        prime_nums = [2, 3]
    else:
        prime_nums = []

    while i <= n:
        while l[i] > k:
            result = l[i]%k
            k = k+1
            if result == 0:
                break
            if (l[i]-1 == k) and (result != 0):
                prime_nums.append(l[i])

        i, k = i+1, 2

    #return prime_nums
    return len(prime_nums)

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

l = len(array)
for i in array:
    psum = prime(i)
    print(psum)

Python: import sys
a=[0,0,1]+[1,0]*499999
for i in range(3,999,2):
 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 sys

N = 1000000
lst = [1] * N
for i in range(3, int(N**0.5)+1, 2):
    if lst[i] == 1:
        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] == 1]
print(lst[:100:])
for i in sys.stdin:
    for j in range(len(lst)):
        if lst[j] > int(i):
            print(j)
            break

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*2, n+1, c):
            l[k-1] = 0
        c = l[:c].index(1) + c
    return sum(l)
for n in stdin:
    n = int(n)
    print(cntPrime(n))