Go: package main
import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	//"math"
)

var sc = bufio.NewScanner(os.Stdin)

func main(){
	for sc.Scan(){
		n := nextInt()
		fmt.Println(calc(n))
	}
}

func calc(n int)int{
	// エラトステネスで数え上げる
	// 最初から999999まで用意しておいて入力のたびO(1)で出すのとどっちが速いのかはわからん
	eratos := make([]bool, n+1)
	c := 0
	for i:=2; i<len(eratos); i++{
		if eratos[i] == false{
			c++
			for j:=i*i; j<len(eratos); j+=i{
				eratos[j]=true
			}
		}
	}
	return c
}

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

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

Python: while True:
    ss=input()
    if len(ss)==0:
        break
    s=int(ss)+1
    if s<2:
        print(0)
    else:
        list=[True]*s
        list[0]=False
        list[1]=False
        i=2
        while i**2<=s-1:
            j=i*2
            while j<=s-1:
                list[j]=False
                j+=i
            i+=1
        print(list.count(True))

Python: import math
while True:
    try:
        n=int(input())
        num=list(range(n+1))
        num[1]=0
        for i in range(n):
            if num[i]>pow(n,0.5):
                break
            if num[i]==0:
                continue
            for j in range(num[i]*2, n+1, num[i]):
                num[j]=0
        print(n+1-num.count(0))
    except:
        break

Python: import numpy as np
while 1:
	num = int(input())
	n = [] #素数をかくのするためのリスト
	li = [] #2から入力された値までのすべての数を格納するリスト
	
	#2から入力された値までのすべての数を格納
	li = [i for i in range(2,num+1)]
	
	#liリストの0番目が入力された値の平方根以下になるまでloop
	while li[0] <= int(np.sqrt(num)):
		n.append(li[0]) #nリストにliリストの0番目を追加
		sss = li[0] #sssにliリストの0番目を格納
		li = [i for i in li if i % sss != 0] #素数判定
	n.extend(li) #liリストに残った数を素数としてnリストに格納
	print(len(n))

Python: # coding: utf-8

import sys
import math


if __name__ == '__main__':
	input_list = sys.stdin.readlines()

	for num in input_list:
		target_number = int(num.replace('\n', ''))
		serial_number_list = [r for r in range(2, target_number + 1)]
		multiple_list = []

		while math.sqrt(target_number) >= serial_number_list[0]:
			serial_number = serial_number_list[0]
			i = 1
			multiple_list.append(serial_number)

			while target_number >= serial_number * i:
				
				if serial_number * i in serial_number_list:
					serial_number_list.pop(serial_number_list.index(serial_number * i))

				i += 1

		print(multiple_list + serial_number_list)

Python: from sys import stdin

def prime(n: int) -> int:
    Prime = [i for i in range(n+1)]
    for i in range(2,n+1):
            for j in range(2,int(n/i)+1):
                Prime[i*j] = 0
    Prime[0],Prime[1] = 0,0
    print(Prime)
    ans = [i for i in Prime if not(i == 0)]
    return len(ans)


n = int(input())
print(prime(n))

Python: import sys

x = 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 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 map(int,sys.stdin):
 print([e-1,sum(s[:(e+1)//6])+sum(t[:(e-1)//6])+2][e>3])

Python: # coding: utf-8
# Your code here!

MAX = 1000000
s = [1] * MAX
s[0] = 0
s[1] = 0

start = 2
while True:
    pmb = 0
    for i in range(start, MAX):
        if s[i] == 1:
            pmb = i
            break
   
    if pmb == 0:
        break

    for i in range(pmb ** 2, MAX, pmb):
        s[i] = 0

    start += 1
    
while True:
    try:
        n = int(input())
        
        c = 0
        for i in range(2, n + 1):
            if s[i] == 1:
                c += 1
        print(c)

    except EOFError:
        break

Python: while True:
    try:
        n = int(input())
        count = 0
        if n == 1:
            print("0")
        else:
            a = [2*i for i in range(2, 1000000)]
            b = [3*i for i in range(2, 1000000)]
            c = [5*i for i in range(2, 1000000)]
            d = [7*i for i in range(2, 1000000)]
            for i in range(2, n+1):
                if i not in a and i not in b and i not in c and i not in d:
                    count += 1
            print(count)
    except:
        break

Python: n = 1000000
a = [True for i in range(n)]
i = 3
while i * i < n:
    for j in range(3 * i, n, 2 * i): a[j] = False
    i += 2
 
while True:
    try:
        b = int(input())
    except:
        break
 
    count = int(b >= 2) + sum(a[i] for i in range(3, b + 1, 2))
    print(count)

Python: def sieve(n):
    p=[True for i in range(n+1)]
    p[0]=p[1]=False
    end=int(n**0.5)

    for i in range(2,end+1):
        if p[i]:
            for j in range(i*i,n+1,i):
                p[j]=False

    return p

def solve(n):
    if n<2:return 0
    cnt=1
    for i in range(3,n+1,2):
        if p[i]:cnt+=1

    return cnt

p=sieve(int(1e6))

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

Python: import math

def is_prime_num(in_num):
    cnt = 0
    if in_num == 2:
        return True
    elif in_num <= 1:
        return False
    elif in_num % 2 == 0:
        return False
    else:
        max_num = int(math.sqrt(in_num))
        for j in range(3, in_num, 2):
            if in_num % j == 0:
                cnt = cnt + 1
                break
                    
        if cnt == 0:
            #?´???°
            return True
        else:
            return False


while True:
    try:
        n = int(input())
        prime_cnt = 0

        for i in range(2, n+1):
            if is_prime_num(i):
                #?´???°
                prime_cnt = prime_cnt + 1
                

        print(str(prime_cnt))
    except:
        break

Python: import sys

MAX = 999999
L = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]

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 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_list(n):
  result = []
  if n >= 2:result.append(2)
  for i in range(3,n+1,2):
    if is_prime(i):result.append(i)
  return result

L2 = prime_list(MAX)

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

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