Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		a, _ := strconv.Atoi(sc.Text())
		fmt.Println(countPrime(a))
	}
}

func countPrime(a int) int {
	primes := make([]bool, a+1)
	n := 0
	for i := 2; i <= a; i++ {
		if primes[i] == false {
			n++
			for j := i * i; j <= a; j += i {
				primes[j] = true
			}
		}
	}
	return n
}

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


def sieve(ks):
    rejected_set = {x for x in ks for i in range(
        1, x) for j in range(i, x) if i + j + 2 * i * j == x}
    return {2} | {2 * y + 1 for y in (ks - rejected_set)}


def number_of_primes(n):
    return len({p for p in sieve(set(range(1, n + 1))) if p <= n})


def main():
    raw_args = []
    while True:
        try:
            raw_args.append(input())
        except EOFError as e:
            break
    for n in map(int, raw_args):
        print(number_of_primes(n))

if __name__ == "__main__":
    main()

Python: def isprime(x):
    if x == 2:
        return True
    elif x < 2 or x%2 == 0:
        return False
    i = 3
    while i <= pow(x,1/2):
        if x%i == 0:
            return False
        i = i + 2
    return True
import sys
import itertools as it
line = sys.stdin.readlines()
for n in line:
    n = int(n)
    if n == 2:
        print(1)
    else:
        count = 1
        for s in range(3,n+1,2):
            if isprime(s):
                count += 1
    print(count)

Python: from math import sqrt
n = 1000000
l = [1]*n
c = [0]*n
d = 0
l[1]= l[0] = 0
for i in range(4,n,2):
    l[i] = 0
for i in range(9,n,2):
    for j in range(3,int(sqrt(i))+1,2):
        if i % j == 0:
            l[i] = 0
            break
for i in range(n):
    if l[i] == 1:
        d += 1
    c[i] = d
while True:
    try:
        n = int(input())
        print(c[n])
    except:
        exit()

Python: import sys

primes = [2]
for line in sys.stdin:
  try:
    n = int(line)
    if n > max(primes):
      for i in range(max(primes) + 1, n + 1):
        if i % 2 == 0:
          continue
        primes.append(i)
        for p in primes:
          if i % p == 0 and i != p:
            primes.pop()
            break
    ans = [i for i in primes if i <= n]
    print(len(ans))
  except:
    break

Python: import math
while True:
  try:
    n = int(input())
    primes = [1] * (n+1)
    for i in range(2, int(math.sqrt(n))+1):
      if primes[i] == 1:
        for j in range(i*i, n+1, i):
          primes[j] = 0
    print(sum(primes)-2) 
  except EOFError:
    break

Python: a=[0]+[1]*10*6
for i in range(999):
 if a[i]:
  a[i*2+1::i+1]=[0 for e in range(len(li[i*2+1::i+1]))]
for e in sys.stdin:print(len([i for i in li[:int(e)]if i]))

Python: import sys
import math

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

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

for i in range(int(math.sqrt(N))+1,N+1,2):
    primes[i//2] += primes[i//2-1]


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

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

print(pr[:100])

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: def main():
    List=[]
    while True:
        try:
            IN=int(input())
            for i in range(2,IN+1):
                List.append(i)

            j=0
            while (j+1)<=len(List):
                l=len(List)
                for k in range(l-1,j,-1):
                    a=List[k]%List[j]
                    if a==0:
                        del List[k]
                    else:
                        pass

                j+=1

            print(len(List))
                    
        
        except:
            break

Python: import math
import sys

def count_primes(n):
    is_prime = [True] * n
    is_prime[0] = is_prime[1] = False
    up = math.sqrt(n)
    primes = [2]
    while True:
        nxt = None
        for i in range(primes[-1] + 1, n + 1):
            if i % primes[-1] == 0:
                is_prime[i-1] = False
            else:
                if nxt is None:
                    nxt = i
        if primes[-1] >= up:
            cnt = 1
            for b in is_prime:
                if b is True:
                    cnt +=1

                
            return cnt 

        primes.append(nxt)


print(count_primes(100))

for line in sys.stdin.readlines():
    n = int(line)
    if n < 2:
        print(0)
    else:
        print(count_primes(n))

Python: import sys
import math

def Prime():
    isPrime=[1 for i in range(0,1000000)]
    isPrime[0]=isPrime[1]=0
    numPrime=[0 for i in range(0,1000000)]

    for i in range(2,int(math.sqrt(1000000)+1),1):
        if isPrime[i]==1:
            numPrime[i]=numPrime[i-1]+1
            for j in range(i+i,1000000,i):
                isPrime[j]=0
        else:
            numPrime[i]=numPrime[i-1]


    for n in sys.stdin:
        print(numPrime[int(n)])
    

#testWriteFile()
Prime()

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 = 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: import sys
results = {}
def fact(n):
    if n in results:
        return results[n]
    ret = [1]
    if n%2==0:
        ret.append(2)
        results[n]=ret
        return ret
    for i in range(3,int(n**0.5)+1,2):
        if n%i==0:
            ret.append(i)
            results[n]=ret
            return ret
    results[n]=ret
    return ret
prime_results = {}
def isPrime(n):
    if n in prime_results:
        return prime_results[n]
    if n<=1:
        prime_results[n]=False
        return False
    if n==2:
        prime_results[n]=True
        return True
    if fact(n)==[1]:
        prime_results[n]=True
        return True
    else:
        prime_results[n]=False
        return False
lines = sys.stdin.readlines()
answers = {}
for line in lines:
    inp = int(line)
    if inp in answers:
        print(answers[inp])
        continue
    s=0
    for i in range(2,inp+1):
        if isPrime(i):
            s+=1
        answers[i]=s
    print (s)

Python: def Eratosthenes(n):
	N = [1 for i in range(0,n+1)]
	i = 3
	while i*i<=n:
		if N[i]:
			j = i*3
			while j<=n:
				N[j] = 0
				j += i*2
		i += 2
	return N

while True:
	N = Eratosthenes(999999)
	try:
		n = int(input())
	except EOFError:
		break
	cnt = 0
	if n>=2:
		cnt = 1
	for i in range(3, n+1, 2):
		cnt += N[i]
	print(cnt)

Python: import sys
from math import sqrt
from itertools import takewhile
prime = [2]
n_list = list(map(lambda x:int(x.rstrip("\n")),sys.stdin.readlines()))
for n in n_list:
    if prime[-1] < n:
        for x in range(prime[-1]+1,n+1):
            if all(map(lambda p:x % p != 0,filter(lambda z:sqrt(x) >= z,prime))):
                prime.append(x)

    print(len(list(takewhile(lambda x:x <= n, prime))))

Python: import math
import sys
isPrime=[False, False]
for i in range(2,1000000):
    isPrime.append(True)
for i in range(2,int(math.sqrt(1000000))):
    if isPrime[i]:
        for j in range(i*i, 1000000, i):
            isPrime[j]=False
nPrime=[]
cnt=0
for i in range(0,1000000):
    if isPrime[i]:
        cnt=cnt+1
    nPrime.append(cnt)
for l in sys.stdin:
    print(nPrime[int(l)])