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: N = 1000000
p = [1] * N

(p[0],p[1]) = (0,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]

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

Python: def eratosthenes(n):
  multiples = set()
  for i in range(2, n+1):
    if i not in multiples:
      yield i
      multiples.update(range(i*i, n+1, i))

while True:
  try:
    print(len(list(eratosthenes(int(input())))))
  except:
    break

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

Python: import sys

array = []
for line in sys.stdin:
    array.append(int(line))

max_val = max(array)
prime_list = [1] * max_val
prime_list[0] = 0
prime_list[1] = 0

i = 2
while i < max_val:
    for j in range(i * 2, max_val, i):
        prime_list[j] = 0
    i = i + 1
    while i < max_val and prime_list[i] == 0:
        i = i + 1

for val in array:
    count = sum(prime_list[:val + 1])
    print(count)

Python: def isprime(n):
    p = 3
    while p * p <= n:
        if n % p == 0: return False
        p += 2
    return True

while True:
    try:
        n = int(input())
    except:
        break

    count = int(n >= 2)
    for p in range(3,n + 1,2):
        if isprime(p): count += 1
    print(count)

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