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_calc(n):
    if n < 2:
        return False
    else:
        i = 2
        while n > i:
            if n % i == 0:
                return False
            else:
                i += 1
    return True

def prime(n):
    cnt = 0
    for i in range(0, 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: 
def isp(n):
    a = 1
    for i in range(2, (n + 1) // 2 + 2):
        if not n % i:
            a = 0
            break
    return a


for i in sys.stdin:
    n = int(i)
    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: def prime_number(n):
    cache = {2} 
    a = 2 
    while a <= n:
        if n < 2:
            cache = {}
            break
        if not a in cache:
            if not [x for x in cache if a % x == 0]: 
                cache.add(a)
        a+=1
    print(len(cache))

try:
    while True:
        n=int(input())
        prime_number(n)
except:
    pass

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

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

print(count)

Python: import math
import sys

MAX_V = 999999
prime = [1] * (MAX_V+1)
prime[0], prime[1] = [0, 0]
sum = [0] * (MAX_V+2)

for i in range(2, math.ceil(math.sqrt(MAX_V))+1):
    if prime[i]:
        for k in range(2*i, MAX_V+1, i):
            prime[k] = 0
for i in range(MAX_V+1):
    sum[i+1] = sum[i] + prime[i]
for line in sys.stdin.readlines():
    print(sum[int(line)+1])

Python: import sys
pr = [1]*1000000
pr[0] = 0
pr[1] = 0
for i in range(2,int(len(pr)/2)):
	if pr[i]==1:
		j = i*2
		while j < int(len(pr)/2):
			pr[j] = 0
			j += i

for line in sys.stdin:
	n = int(line)
	cnt = 0
	for i in range(n+1):
		if pr[i]==1:
			cnt += 1
	print(cnt)

Python: L = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]

def is_prime_2(n):
  a = int(n ** 0.5)
  for i in L:
    if i > a:return True
    if n % i == 0:return False
  return True

def prime_count(n):
  result = 0
  if n >= 2:result+=1
  for i in range(3,n+1,2):
    if is_prime_2(i):result+=1
  return result

while 1:
  print(prime_count(int(input())))

Python: import sys
m=166666;s=[1]*m;t=[1]*m
for i in range(m):
 if s[i]:
  k=6*i+5
  s[i+k::k]=[0]*len(s[i+k::k])
  t[-2-i+k::k]=[0]*len(t[-2-i+k::k])
 if t[i]:
  k=6*i+7
  s[-2-i+k::k]=[0]*len(s[-2-i+k::k])
  t[i+k::k]=[0]*len(t[i+k::k])
for e in sys.stdin:
 e=int(e)
 print([e-1,sum(s[:(e+1)//6])+sum(t[:(e-1)//6])+2][e>3])

Python: t = 0
while t == 0:	
	prime = [2]
	try:
		n = int(input())
	except:
		break
	#?¨??????\???????????????????¨????
	else:
		if n == 1:
		#1?????????
			print(0)
		else:
			for a in range(2,n + 1):
			#2??\????????????
				total = len(prime)
				#?´???°?????°?????????
				for b in prime:
					if a % b == 0:
						break
						#?´???°??????????????´????????????	
					else:
						if total == 0:
						#?´???°?¢?????????????
							prime.append(a)
						else:
						#?´???°??¢?´¢??°??????
							total -= 1
			print(len(prime))

Python: t = 0
while t == 0:	
	prime = [2,3]
	try:
		n = int(input())
	except:
		break
	#?¨??????\???????????????????¨????
	else:
		if n == 1:
		#1?????????
			print(0)
		elif n == 2:
			print(1)
		else:
			a = 5
			while a > n:
			#5??\????????????
				total = len(prime)
				#?´???°?????°?????????
				for b in prime:
					if a % b == 0:
						break
						#?´???°??????????????´????????????	
					else:
						if total == 0:
						#?´???°?¢?????????????
							prime.append(a)
						else:
						#?´???°??¢?´¢??°??????
							total -= 1
				if (a + 1) % 6 == 0:
					a += 2
				else:
					a += 5
			print(len(prime))

Python: import sys
import math

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

for i in range(3,int(math.sqrt(N)),2):
    j = i//2
    if primes[j]:
        primes[i*j::i] = [0] * len(primes[i*j::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: # -*- coding: utf-8 -*-

import sys


def prime(n):
    s = [i for i in range(2,n+1)]
    p = []
    while s[0] < n**0.5:
        p.append(s[0])
        for ss in s:
            if ss % p[-1] == 0:
                s.remove(ss)
    p.extend(s)
    return p

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

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: for input in sys.stdin:
    prime_num = 0
    for i in range(int(input)):
        y = i+1
        x = y / 2
        while x > 1:
            if y % x == 0:
                break
            x -= 1
        else:
            prime_num += 1
    print(prime_num-1)

Python: def Eratosthenes(n):
	N = {i:True for i in range(2,n+1)}
	primeNumbers = []
	for i in range(2,n+1):
		if N[i]:
			primeNumbers.append(i)
			j = i*2
			while j<=n:
				N.update({j:False})
				j += i
	return primeNumbers

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