Go: package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = 1
        }
        primes[0] = 0
        primes[1] = 0
        Soe()
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := i*2; j < MAX; j+=i {
                                primes[j] = 0
                        }
                }
        }
}

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)])

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

Python: import sys
import math

def isPrime(n):
    if n < 2:
        return 0
    elif n == 2:
        return 1
    elif n%2 == 0:
        return 0   
    num = int(math.sqrt(n))
    for i in range(3, num+1, 2):
        if n%i == 0:
            return 0
    return 1;

while True:
    try: 
        n = int(input())
        cnt = 0
        for i in range(2, n+1):
            cnt += isPrime(i)
        print(cnt)
    
    except EOFError:
        sys.exit()

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

while True:
    try:
        n=int(input())
        cnt=0
        for x in range(2,n+1):
            if isPrime(x)==True:
                cnt+=1
        print(cnt)
    except:
        break

Python: import math


def sieve_of_erastosthenes(num):
    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

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


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

        if 5 >= n:
            print(1)

        else:
            input_list = sieve_of_erastosthenes(n)

            print(sum(input_list))

Python: from math import sqrt, ceil

N = 1000000
temp = [True]*(N+1)
temp[0] = temp[1] = False
for i in range(2, ceil(sqrt(N+1))):
    if temp[i]:
        temp[i+i::i] = [False]*(len(temp[i+i::i]))

while True:
    try:print(len([1 for _ in temp[:int(input())+1] if _]))
    except:break