Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func check(n int) int {
	eratos := make([]bool, n+1)
	cnt := 0
	for i := 2; i < len(eratos); i++ {
		if !eratos[i] {
			cnt++
			for j := i*i; j < len(eratos); j += i {
				eratos[j] = true
			}
		}
	}
	return cnt
}

func main() {
	for scanner.Scan() {
		n := nextInt()
		fmt.Println(check(n))
	}
}

Python: def ct(num):
    primel=[2]
    for i in range(2,num+1): 
        for e in primel:
            if i%e==0:break
        else:primel.append(i)
    return len(primel)        
    
while True:
    try:raw=[int(i) for i in input().split(" ")]
    except:break
    a=raw[0]
    print(str(ct(a)))

Python: N = 1000000
p = [ 1 ] * N

( p[ 0 ], p[ 1 ] ) = ( 0, 0 )
for i in range ( len ( p ) ):
  if ( p[ i ] ):
    for j in range ( i * 2, len ( p ), i ):
      p[ j ] = 0
for i in range ( 1, len ( p ) ):
  p[ i ] += p[ i - 1 ]

while True:
  try: n = int ( input ( ) )
  except EOFError: break
  print ( p[ n ] )

Python: import sys
import time

MAX = 999999

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

def prime_list(n):
  return ([2] if n > 1 else []) + [i for i in range(3,n+1,2) if is_prime(i)]

L = prime_list(int(MAX**0.5))

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

def prime_list2(n):
  return ([2] if n > 1 else []) + [i for i in range(3,n+1,2) if is_prime_2(i)]

L2 = prime_list2(MAX)

def prime_count_2(n):
  for i,v in enumerate(L2):
    if v > n:return i
  return len(L2)

for n in sys.stdin:
  print(prime_count_2(int(n)))

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

Python: import sys

f = [0, 1] * 500000
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: 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)
        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]:
                if target*k in search_list:
                    search_list.remove(target*k)
                k += 1
        print(len(prime_list))
        target = 0
        k = 0
        prime_list.clear()
        search_list.clear()

Python: import math
import sys

def prime_calc(n):
    rootN = math.floor(math.sqrt(n))
    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: import math
import sys

def f(L):
    if isinstance(L, list):
        if L == []:
            return []
        else:
            return f(L[0]) + f(L[1:])
    else:
        return [L]

def E(d):

    p_list = [] 
    tmp = []
    num = int(math.sqrt(len(d)))+1
    for i in d:
        i=d[0]
        if i>num:
            break
        else:
            p_list.append(i)
            for j in d:
                if j%i == 0:
                    d.remove(j)
        
    p_list.append(d)
    return p_list

lists = []
for line in sys.stdin:
    x= list(range(2,(int(line)+1)))
    print(len(f(E(x))))

Python: import sys
for line in sys.stdin:
    count = 0
    n = int(line)
    if n>=2: count += 1
    for i in range(3,n+1,2):
        if pow(2,i-1,i)==1: count += 1
    print(count)

Python: while 1:
    try:
        count=0;
        x=int(input())
        if x==1:
            print(0)
        elif x==2:
            print(1)
        else:
            a=[int(i) for i in range(2,x+1)]
            for i in  range(len(a)):
                count1=0
                for j in range(2,a[i]):
                    if a[i]%j==0:
                        count1+=1
                if count1==0:
                    count+=1
            print(count)        
    except EOFError:
        break

Python: import sys

def create_prime_list(limit):
    """ ??¨??????????????????????????§limit?????§????´???°?????????????±???????
    https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9
    """
    x = limit**0.5
    primes = []
    nums = tuple(x for x in range(2, limit+1))
    while nums[0] <= x:
        primes.append(nums[0])
        current_prime = nums[0]
        nums = tuple(x for x in nums if x % current_prime != 0)
    primes.extend(nums)
    return primes


if __name__ == '__main__':
    # ?´???°?????§?????¨???
    primes = create_prime_list(999999)

    # ??????????????\???
    for line in sys.stdin:
        target = int(line)

        ans = tuple(x for x in primes if x <= target)
        print(len(ans))

Python: def Eratosthenes(n):
	N = [1 for i in range(0,n+1)]
	i = 3
	while i*i<=n:
		if N[i]:
			j = i*i
			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
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):
        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: from sys import stdin

def isprime(n):
    from math import floor,sqrt
    if n <= 1:
        return False
    for i in range(2,floor(sqrt(n))+1):
        if n % i == 0:
            return False
    return True

N = []
for line in stdin:
    N.append(int(line))
for i in N:
    ans = 0
    for j in i:
        if isprime(j):
            ans += 1
    print(ans)

Python: import argparse

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 = []

    parser = argparse.ArgumentParser()
    parser.add_argument("filename", help="The filename to be processed")
    args = parser.parse_args()

    if args.filename:
        with open(args.filename) as f:
            for line in f:
                a = int(line.rstrip())
                l.append(a)

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

if __name__ == "__main__":
    main()