Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		input := nextInt()
		fmt.Println(IsPrime(input))
	}
}

func IsPrime(num int) int {
	eratos := make([]bool, num+1)
	c := 0
	for i := 2; i < len(eratos); i++ {
		if eratos[i] == false {
			c++
			eratosCalc(i, eratos)
		}
	}
	return c
}

func eratosCalc(primeNum int, eratos []bool) {
	for i := primeNum * primeNum; i < len(eratos); i += primeNum {
		eratos[i] = true
	}
}

func next() string {
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

Python: import sys

l = [True] * 100000
for i in range(2, 100000):
    if (l[i - 1]):
        for j in range(i ** 2 - 1, 100000, i):
            l[j] = False
for n in sys.stdin.readlines():
    print(l[1:int(n)].count(True))

Python: LIMIT = 10000000
  
isPrime = [True for _ in range(LIMIT)]
 
isPrime[0] = isPrime[1] = False
  
for i in range(2, int(LIMIT ** 0.5)+1):
  if isPrime[i]:
    for j in range(i * i, LIMIT, i):
      isPrime[j] = False
  
try:
    while True:
        n = int(input())
 
        count = 0
        if n >= 2:
            count = 1
 
        for i in range(3, n+1, 2):
            if isPrime[i]:
                count += 1
 
        print(count)
except EOFError:
  pass

Python: import math

def main():
    while True:
        try:
            n = int(input())
            count = 0
            for x in range(2,n+1):
                flag = 0
                for i in range(2,int(n**0.5)):
                    if x%i == 0:
                        flag = 1
                        break
                if flag == 0:
                    count += 1
            print(count)      
        except EOFError:
            exit()
      

if __name__ == '__main__':
    main()

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)
        #print(sqrt(int(array[i])))
        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]:
                #print(target * k)
                if target*k in search_list:
                    search_list.remove(target*k)
                k += 1
            #print(search_list)
        #print(str(array[i]) + "??\???????´???°???" + str(prime_list) + "??????????????°???" + str(len(prime_list)))
        print(len(prime_list))
        target = 0
        k = 0
        prime_list.clear()
        search_list.clear()

Python: import sys
from math import floor, sqrt
from bisect import bisect_right

primes = [2]

def isPrime(v):
    threshold = floor(sqrt(v))
    for p in primes:
        if p > threshold:
            break
        if v % p == 0:
            return False
    return True

for v in range(3, 1000000, 2):
    if isPrime(v):
        primes.append(v)

print(len(primes))

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

for v in values:
    print(bisect_right(primes, v))

Python: # -*- coding: utf-8 -*-

import sys


def eratosthenes_sieve(n):
    table = [0]*(n + 1)
    prime_list = []
    
    for i in range(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i + i, n + 1, i):
                table[j] = 1
    return prime_list


def prime(n):
    return eratosthenes_sieve(n)

def main():
    inp = [int(n) for n in sys.stdin]
    for n in inp:
        n_pn = len(prime(n))
        print(n_pn)

if __name__ == '__main__':
    main()

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

Python: import math
num_max = 999999
i = 3
prime_list = [2]
while i<num_max :
	judge = True
	j = 0
	while prime_list[j] <= math.sqrt(i) :
		if (i%prime_list[j]==0) :
			judge = False
			break
		j += 1
	if(judge) :
		prime_list.append(i)
	i += 2

n = input()
k = 0
while prime_list[k] <=  n :
    k += 1

print(k)

Python: from math import sqrt,floor

def isPrime(x):
  if x==1:
    return 0
  for i in range(2,1+floor(sqrt(x))):
    if x%i == 0:return 0
  return 1

inputs=[]

while True:
  try:
    inputs.append(int(input()))
  except EOFError:
    break

for i in inputs:
  a = 0
  for j in range(1,i+1):
    a+=isPrime(j)
  print(a)

Python: # coding: utf-8
# 79
N=[]

while True:
    try:
        N.append(int(input()))
    except:
        break

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n+ 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

s = primes(max(N))

for k in N:
    A=len([x for x in s if x <= k])
    print(A)

Python: import math
import sys

def get_primes(n):
    search = list(range(2, n+1))
    primes = []
    while True:
        primes.append(search[0])
        for i,x in enumerate(search):
            if x % primes[-1] == 0:
                del search[i]
        if len(search) == 0 or search[0] >= math.sqrt(n):
            primes.extend(search)
            return primes

for line in sys.stdin.readlines():
    n = int(line)
    print(len(get_primes(n)))

Python: from math import sqrt
def eratosthenes(n):
  def era(x,p):
    if x<=p or (x>p and x%p!=0):
      return x
    else:
      return None
  A=[i for i in range(2,n+1)]
  p=2
  while p<=sqrt(n):
    A=list(filter(lambda x:era(x,p),A))
    p+=1
  return(A)

inputs=[]
while True:
  try:
    inputs.append(int(input()))
  except EOFError:
    break

for i in inputs:
  print(len(eratosthenes(i)))

Python: import sys
MAX = 1000000

A = tuple(range(2, MAX))
B = tuple()
while True:
    if (A[0])**2 > MAX:
        break
    B = B + (A[0],)
    A = tuple(x for x in A if x % A[0] != 0)
B = B + A

Lines = sys.stdin.readlines()
for line in Lines:
    print(len([x for x in B if x <= int(line)]))

Python: import math
def sosu(n) :
    for i in range(3, int(math.sqrt(n))+1, 2) :
        if n % i == 0 :
            return False
    return True

S = [0, 0, 1, 2, 2, 3, 3, 4, 4, 4, 4]
for i in range(11, 1000000) :
    if i % 2 == 0 :
        S.append(S[i-1])
    elif sosu(i) :
        S.append(S[i-1]+1)
    else :
        S.append(S[i-1])


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

Python: import sys
e=list(map(int,sys.stdin))
m=max(e)+1;a=[1]*m;a[0:2]=0,0
for i in range(2,int(m**.5)+1):
 if a[i]>0:
  for j in range(i*2,m,i):a[j]=0
for i in range(m):a[i]+=a[i-1]
for x in e:print(a[x])