Go: package main

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

func main() {
    var limit = 1000000
    var root = 1000
    var isPrime [1000000]bool
    for i := 0; i < limit; i++ {
        isPrime[i] = true
    }
    isPrime[0] = false
    isPrime[1] = false
    for i := 2; i <= root; i++ {
        if isPrime[i] {
            for j := i * i;j < limit; j+=i {
                isPrime[j] = false
            }
        }
    }
    var primeCnt [1000000]int
    var cnt = 0
    for i := 0; i < limit; i++ {
        if isPrime[i] {
            cnt++
        }
        primeCnt[i] = cnt
    }

    var sc = bufio.NewScanner(os.Stdin)
    for sc.Scan() {
        n, _ := strconv.Atoi(sc.Text())
        fmt.Println(primeCnt[n])
    }
}

Python: #!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
import sys

def is_prime(x):
    if x == 2:
        return True

    if x < 2 or x%2 == 0:
        return False

    i = 3
    while i <= int(math.sqrt(x)):
        if x%i == 0:
            return False
        i += 2

    return True

for line in sys.stdin.readlines():
    n = int(line.strip())
    num_prime = 0
    for x in range(1, n + 1):
        if is_prime(x):
            num_prime += 1
    print(num_prime)

Python: while True:
    try:
        n = int(input())
        num = list(range(n + 1))
        num[1] = 0
        for i in range(n):
            if num[i] > 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 sys
import math

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

for i in range(3,int(math.sqrt(N)),2):
    if primes[i//2]:
        primes[(i*i)//2::i] = [0] * len(primes[(i*i)//2::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: import sys
for line in sys.stdin.readlines():
  n = int(line)
  count_ = 0
  for i in range(n):
    count = 0
    for j in range(i+1):
      if (i+1) % (j+1) == 0:
        count += 1
    if count == 2:
      count_ += 1
  print(count_)

Python: import sys

l = [True] * 1000000
for i in range(2, 1000000):
    if (l[i - 1]):
        for j in range(i ** 2 - 1, 1000000, i):
            l[j] = False

for s in sys.stdin:
    print(l[1:int(s)].count(True))

Python: def e(n):
    array = [1]*(n+1)
        
    k = 2
    
    while k*k <= n:
        if array[k] == 1:
            i = k
    
            while (i <= n/k):
                array[k*i] = 0
                i += 1
        
        k += 1
    
    # ?´???°(array[i]==1)?????????
    prime = []
    i = 2
    
    while i <= n:
        if array[i] == 1:
            prime.append(i)
        i += 1
    
    return len(prime)


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

Python: import sys
def fact(n):
    ret = [1]
    for i in range(2,int(n//2)+1):
        if n%i==0:
            ret.append(i)
    return ret
def isPrime(n):
    if n<=1:
        return False
    if n==2:
        return True
    if fact(n)==[1]:
        return True
    else:
        return False
lines = sys.stdin.readlines()
for line in lines:
    inp = int(line)
    s=0
    for i in range(2,inp+1):
        if isPrime(i):
            s+=1
    print (s)

Python: # coding: utf-8
# Here your code !
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:
        if pow(2, in_num-1, in_num) == 1:
            return True
        else:
            return False
 
while True:
    try:
        n = int(input())
        prime_cnt = 0
        if n >= 2:
            #?????????2???????????????
            prime_cnt = prime_cnt + 1
 
        for i in range(3, n+1, 2):
            if is_prime_num(i):
                prime_cnt = prime_cnt + 1
                  
  
        print(str(prime_cnt))
    except:
        break

Python: str1=[0 for i in range(10**6)]
str1[0]=1
str1[1]=1
for i in range(2,(10**6)):
    if str1[i]==0:
        for j in range(2,(10**6)):
            if i*j>=len(str1):
                break
            else:
                str1[i*j]=1
            
while 1 :
    try:
        x=int(input())
        count=0
        for i in range(1,x+1):
            if str1[i]==0:
                count+=1
        print(count)
        
    except EOFError:
        break

Python: a=[1 for i in range(1000001)]
b=[0,0]
a[0]=a[1]=0
c=0
for i in range(2,1000001):
  if a[i]==1:
    c+=1
    for j in range(i * 2,1000001,i):
      a[j]=0
  b.append(c)
while True:
  try:
    print(b[int(input())])
  except EOFError:
    break

Python: 
def isp(n):
    a = 1
    for i in range(2, (n + 1) // 2 + 2):
        if not n % i:
            a = 0
            break
    return a


num = input(int)
if num == 2:
    print(1)
elif num == 3:
    print(2)
else:
    s = 2
    for x in range(2, num + 1):
        if isp(x):
            s += 1
    print(s)

Python: def main():
	import sys
	from math import sqrt

	MAX = 1000000

	table = [True]*1000000
	table[0] = table[1] = False

	primes = []
	counted = 0

	for i in range(MAX):
		if table[i]:
			primes.append(i)
			for j in range(2*i, MAX, i):
				table[j] = False

	for line in sys.stdin:
		n = int(line)

		cnt = 0
		for prime in primes:
			if prime > n:
				break
			else:
				cnt += 1
		print(cnt)


if __name__ == '__main__':
	main()

Python: def isprime(num):
    if num==1:return False
    if num==2:return True
    for i in range(int(num/2)):
        if num%(i+2)==0:
            return False
        else:continue
    return True
    
def ct(num):
    count=0
    for i in range(num):
        if isprime(i+1):count+=1
    return count

def yak(num):
    if isprime(num):return [1,num]
    if num==1: return[1]
    for i in range(int(num/2)):
        if num%(i+2)==0:
            ret=yak(i+2)+yak(num/(i+2))
            ret.remove(1)
            return sorted([int(i) for i in ret])
    
        
while True:
    try:raw=[float(i) for i in input().split(" ")]
    except:break
    a=raw[0]
    print(str(ct(a)))

Python: def f(n):
    table = [False, False] + [True for _ in range(2, n+1)]
    p = 2
    while p**2 <= n:
        if table[p]:
            j = p + p
            while j <= n:
                table[j] = False
                j += p
        p += 1
    return sum(table)


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

Python: import sys
def main():
    for number in sys.stdin:
        p = 0
        number = int(number)
        for num in range(2, number+1):
            a = int(num**0.5)
            bl = True
            for k in range(2, a+1):
                if num % k == 0:
                    bl = False
                    break
            if bl:
                p += 1
        print(p)
    return None


if __name__ == '__main__':
    main()

Python: while True:
    try:
        n=int(input())
        num=list(range(n+1))
        num[1]=0
        for i in range(n):
            if num[i]>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: # coding: utf-8
# Your code here!

a=[1 for i in range(1000001)]
b=[0,0]
a[0]=a[1]=0
c=0
for i in range(2,1000001):
    if a[i]==1:
        c+=1
        for j in range(i*2,1000001,i):
            a[j]=0
    b.append(c)

while True:
    try:
        print(b[int(input())])
    except EOFError:
        break