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 math


try:
    while True:
        r = int(input())

        A = [i for i in range(2, r+1)]
        P = []
        time = 0

        while True:
            prime = min(A)

            if prime > math.sqrt(r):
                break

            P.append(prime)

            i = 0
            while i < len(A):
                if A[i] % prime == 0:
                    A.pop(i)
                    continue
                i += 1
        for a in A:
            P.append(a)

        print(len(P))

except EOFError:
    pass

Python: import math

def check_prime(goal):
    true_or_false=False
    for i in range(2,int(math.sqrt(goal))+1):
        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: def main():
	import sys

	MAX = 1000000

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

	primes = []
	counted = 0

	for line in sys.stdin:
		n = int(line)
		if n > counted:
			for i in range(int(n+1)):
				if table[i] and not i in primes:
					primes.append(i)
					for j in range(2*i, MAX, i):
						table[j] = False
			counted = n

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


if __name__ == '__main__':
	main()

Python: def prime_judge(n):
    if n==1:
        return False
    elif n==2:
        return True
    elif n%2==0:
        return False
    else:
        sqrt_num=int(n**0.5)+1
        for i in range(3,sqrt_num, 2):
            if n%i==0:
                return False
        return True

prime=[0]
for i in range(1,100000):
    if prime_judge(i):
        prime.append(prime[-1]+1)
    else:
        prime.append(prime[-1])

while 1:
    try:
        print(prime[int(input())])     
    except:
        break

Python: import sys
n=1000000
p=[1]*n
p[0]=p[1]=0
for i in range(n):
  if p[i]:
    for j in range(i*2,n,i):
      p[j]=0
for i in range(1,n):
  p[i]+=p[i-1]

for l in sys.stdin:
  print(p[int(l)])

Python: import sys


def primes(n):
    f = []
    for i in range(n + 1):
        if i > 2 and i % 2 == 0:
            f.append(0)
        else:
            f.append(1)
    i = 3
    while i * i <= n:
        if f[i] == 1:
            j = i * i
            while j <= n:
                f[j] = 0
                j += i + i
        i += 2
    return f[2:]


if __name__ == "__main__":
    ps = primes(100)
    for i in sys.stdin:
        print(i,sum(ps[:i-1]))

Python: import sys
lines = sys.stdin.readlines()
for line in lines:
    a = int(line)
    b = [False, False]
    for i in range(a-1):
        b.append(True)
    for i in range(a):
        if(b[i]):
            k = i
            while(k <= a-i):
                k += i
                b[k] = False
    #print(b)
    cnt = 0
    for i in b:
        if(i):
            cnt += 1
    print(cnt)

Python: import math
import sys

def prime_calc(n):
    rootN = int(n**0.5)
    prime = [2]
    data = [i + 1 for i in range(2,n,2)]
    while True:
        p = data[0]
        if rootN <= p:
            return len(prime + data)
        prime.append(p)
        data = [e for e in data if e % p != 0]

def main():
    l = []

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

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

if __name__ == "__main__":
    main()

Python: o_list=[]
while True:
	try:
		n=int(input())
		I_list=[i for i in range(2,n+1)]
		prime_list=[]
		for i in I_list:
			k=I_list[0]
			prime_list.append(k)
			for j in I_list:
				if j%k==0:
					I_list.remove(j)

		K=set(I_list) | set(prime_list)
		K=list(K)
		K=sorted(K)
		o_list.append(len(K))
	except:
		for i in o_list:
			print(i)
		break

Python: import math

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

Python: import sys

prime = [2,3,5,7,11,13,17,19,23,29,31]

shieve1 = [1]*1001
for i in prime:
    itr = i-1
    while(itr<1000):
        shieve1[itr] = 0
        itr += i

for i in range(32,1000):
    if shieve1[i]:
        prime.append(i+1)

shieve2 = [1]*(10**6+1)

for i in prime:
    itr = i-1
    while(itr<10**6):
        shieve2[itr] = 0
        itr += i

for i in range(1001,10**6+1):
    if shieve2[i]:
        prime.append(i+1)

for line in sys.stdin:
    n = int(line)
    cont = 0
    for i in prime:
        if i<=n:
            cont += 1
        else:
            break
    print(cont)

Python: prime_num=[2]
while(True):
	try:
		date=int(input())
	except:
		break
	if(date==1):
		print(1)
		continue
	prime_num=[2]
	for i in range(3,date+1):
		flag=True
		j=0
		while(True):
			if(i**0.5<prime_num[j]):
				break
			if(i%prime_num[j]==0):
				flag=False
				break
			j+=1
		if(flag):
			prime_num.append(i)
	print(len(prime_num))

Python: import math

def IsPrimer(num):
	if num == 1:
		isprimer = False
	else:
		isprimer = True
		for divisor in range(2, int(math.sqrt(num)) + 1):
			if num % divisor == 0:
				isprimer = False
				break
	return isprimer

while True:
	try:
		num = eval(input())
		count = 0
		for i in range(2, num + 1):
			if IsPrimer(i):
				count += 1
		print(count)
	except EOFError:
		break

Python: import sys
a=[1]*500000
for i in range(3,999,2):
 if a[i//2]:a[i*i//2::i]=[0]*len(a[i*i//2::i])
for e in map(int,sys.stdin):print([e-1,sum(a[:(e+1)//2])][e>3])

Python: from sys import stdin
a = [True]*1000000
for i in range(2,1000000):
    if a[i]:
        for j in range(i+i, 1000000)[::i]:
            a[j] = False

b = [None]*1000000
b[0] = b[1] = 0
for i in range(2,1000000):
    if a[i]:
        b[i] = b[i-1] + 1
    else:
        b[i] = b[i-1]

while True:
    try:
        print(b[int(input())])
    except:
        break