Go: package main

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

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}
		maybePrime := make([]bool, n+1)
		for i := 0; i <= n; i++ {
			maybePrime[i] = true
		}

		maybePrime[0] = false
		maybePrime[1] = false
		for i := 2; i <= int(math.Sqrt(float64(n)))+1; i++ {
			j := i * 2
			for j <= n {
				maybePrime[j] = false
				j += i
			}
		}

		nPrimes := 0
		for _, p := range maybePrime {
			if p {
				nPrimes++
			}
		}
		// fmt.Println(maybePrime)
		fmt.Println(nPrimes)
	}
}

Python: import sys
m=166666;s=[1]*m;t=[1]*m
for i in range(m):
 if s[i]:
  k=6*i+5
  s[i+k::k]=[0]*len(s[i+k::k])
  t[-2-i+k::k]=[0]*len(t[-2-i+k::k])
 if t[i]:
  k=6*i+7
  s[-2-i+k::k]=[0]*len(s[-2-i+k::k])
  t[i+k::k]=[0]*len(t[i+k::k])
for e in sys.stdin:
 e=int(e)
 print([e-1,sum(s[:(e+1)//6])+sum(t[:(e-1)//6])+2][e>3])

Python: t = 0
while t == 0:	
	prime = [2]
	try:
		n = int(input())
	except:
		break
	#?¨??????\???????????????????¨????
	else:
		if n == 1:
		#1?????????
			print(0)
		else:
			for a in range(2,n + 1):
			#2??\????????????
				total = len(prime)
				#?´???°?????°?????????
				for b in prime:
					if a % b == 0:
						break
						#?´???°??????????????´????????????	
					else:
						if total == 0:
						#?´???°?¢?????????????
							prime.append(a)
						else:
						#?´???°??¢?´¢??°??????
							total -= 1
			print(len(prime))

Python: t = 0
while t == 0:	
	prime = [2,3]
	try:
		n = int(input())
	except:
		break
	#?¨??????\???????????????????¨????
	else:
		if n == 1:
		#1?????????
			print(0)
		elif n == 2:
			print(1)
		else:
			a = 5
			while a > n:
			#5??\????????????
				total = len(prime)
				#?´???°?????°?????????
				for b in prime:
					if a % b == 0:
						break
						#?´???°??????????????´????????????	
					else:
						if total == 0:
						#?´???°?¢?????????????
							prime.append(a)
						else:
						#?´???°??¢?´¢??°??????
							total -= 1
				if (a + 1) % 6 == 0:
					a += 2
				else:
					a += 5
			print(len(prime))

Python: import sys
import math

N = 1000000
primes = [1] * (N//2)
primes[0] = 0

for i in range(3,int(math.sqrt(N)),2):
    j = i//2
    if primes[j]:
        primes[i*j::i] = [0] * len(primes[i*j::i])

for i in sys.stdin:
    n = int(i)
    if n == 1:
        print(0)
    elif n == 2:
        print(1)
    else:
        print(sum(primes[0:(n+1)//2])+1)

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

import sys


def prime(n):
    s = [i for i in range(2,n+1)]
    p = []
    while s[0] < n**0.5:
        p.append(s[0])
        for ss in s:
            if ss % p[-1] == 0:
                s.remove(ss)
    p.extend(s)
    return p

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: import sys


xx = 500000
f = [0, 1] * xx

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: import math

def prime_calc(n):
    if n < 2:
        return False
    elif n==2 or n==3 or n==5 or n==7:
        return True
    else:
        rootN = math.floor(math.sqrt(n))
        i = 11
        while rootN > i:
            if n % i == 0:
                return False
            else:
                i += 2

    return True

def prime(n):
    cnt = 0
    for i in range(2, n+1):
        ans = prime_calc(i)
        if ans is True:
            cnt = cnt + 1

    return cnt

def main():
    l = []

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

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

if __name__ == "__main__":
    main()

Python: for input in sys.stdin:
    prime_num = 0
    for i in range(int(input)):
        y = i+1
        x = y / 2
        while x > 1:
            if y % x == 0:
                break
            x -= 1
        else:
            prime_num += 1
    print(prime_num-1)

Python: def Eratosthenes(n):
	N = {i:True for i in range(2,n+1)}
	primeNumbers = []
	for i in range(2,n+1):
		if N[i]:
			primeNumbers.append(i)
			j = i*2
			while j<=n:
				N.update({j:False})
				j += i
	return primeNumbers

while True:
	try:
		n = int(input())
		print(len(Eratosthenes(n)))
	except EOFError:
		break

Python: import sys

ary=[]
for i in sys.stdin:
    ary.append(int(i))
m = max(ary)
prime=[1] * (m + 1)
prime[0] = prime[1] = 0
for i in range(2, int(m ** 0.5) + 1):
    if prime[i] == 1:
        for j in range(i*2, m + 1, i):
            prime[j] = 0
for i in range(len(ary)):
    print(sum(prime[:ary[i] + 1]))

Python: import sys
m=10**5//2
a=[0,0,1]+[1,0]*m
for i in range(4,999):
 if a[i]:a[i*2::i]=[0]*len(a[i*2::i])
for e in sys.stdin:print(sum(a[:int(e)+1]))

Python: while True:
    try:
        num=int(input())
    except:
        break
    sum=0
    for i in range(1,num+1):
        n=0
        for j in range(1,i):
            if i%j==0:
                n+=1
        if n==1:
            sum+=1
    print(sum)

Python: n=1000000
num=[True]*(n+1)
num[0]=num[1]=False

for i in range(2,int(n**0.5)+1):
    if num[i]:
        for j in range(i*2,n+1,i):
            num[j]=False
# 0 1 2 2 3 3 4
# 1 2 3 4 5 6 7
ans=[0]*(n)
for i in range(1,n):
    if num[i]:
        ans[i]=ans[i-1]+1
    else:
        ans[i]=ans[i-1]
while True:
    try:
        s=int(input())
    except:
        break
    print(ans[s])

Python: import math


def sieve_of_erastosthenes(target_list):
    for num in target_list:
        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:
                print(sum(input_list))
                break

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



if __name__ == '__main__':
    target_list = []

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

    sieve_of_erastosthenes(target_list)

Python: import math
  
def yo(n):
    if n==1:    return False
    s=2
    while s <= int(math.sqrt(n)):
        if n%s == 0:    return False
        s+=1
    return True
  
while True:
    c=0
    try:
        for i in range(1, int(input(">>"))+1,2):
            if yo(i)==True:    c+=1
        print(c)
    except:
        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
while True :
    try:
        n = input()
        k = 0
        while prime_list[k] <=  n :
            k += 1
        print(k)
    except EOFError :
        break

Python: def era(x,p):
  if x<=p or (x>p and x%p!=0):
    return x
  else:
    return None
def eratosthenes(n):
  A=[i for i in range(2,n+1)]
  p=2
  while p<=n**(1/2):
    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)))