Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		a, _ := strconv.Atoi(sc.Text())
		fmt.Println(countPrime(a))
	}
}

func countPrime(a int) int {
	primes := make([]bool, a+1)
	n := 0
	for i := 2; i <= a; i++ {
		if primes[i] == false {
			n++
			for j := i * i; j <= a; j += i {
				primes[j] = true
			}
		}
	}
	return n
}

Python: prime=[False]*1000000
np=[0]*1000000
for i in range(2,1000):
    if not prime[i]:
        for j in range(i*2,1000000,i):
            prime[j]=True

while True:
    try:
        n=int(input())
    except:
        break
    print(sum(prime[2:n+1]))

Python: import sys

num = []
for i in sys.stdin:
    num.append(int(i))

lst = [i for i in range(2, max(num))]
for i in lst[::-1]:
    for j in range(2, i):
        if i % j == 0:
            lst.pop(lst.index(i))
            break

for i in num:
    for j in lst:
        if i < j:
            print(lst.index(j))
            break

Python: import math
b=[]
b.append(1)
b.append(2)
count=1
s=0
while s<30:
    try:
        x=int(input())
        if x>b[count]:
            for i in range(b[count]+1,x+1):
                count1=0
                
                for j in range(2,int(math.sqrt(i))+1):
                    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
        s+=1
    except EOFError:
        break

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

# n??\???????´???°?????°???????????¢??°
def prime(n):
    l = range(0,n+1)
    i,k = 0,2
    result = 1

    if n >= 3:
        prime_nums = [2, 3]
    else:
        prime_nums = []

    while i <= n:
        while l[i] > k:
            result = l[i]%k
            k = k+1
            if result == 0:
                break
            if (l[i]-1 == k) and (result != 0):
                prime_nums.append(l[i])

        i, k = i+1, 2

    #return prime_nums
    return len(prime_nums)

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

#l = len(array)
#for i in array:
#    psum = prime(i)
#    print(psum)
    
for i in sys.stdin:
    psum = prime(int(i))
    print(psum)

Python: # ?´???°?????°?????¨?????????????????°??????

import sys
import math

prim_no = {2: True}                    # ????????°????´???°??§??????????????????????????????

def is_prime(no):
    if no == 2 or no == 1:
        return True
    
    if no % 2 == 0:
        return False

    if prim_no.get(no) is not None:
        return prim_no.get(no)

    max_check = int(math.sqrt(no))
    for i in range(3, max_check+1, 2):
        if no % i == 0:
            prim_no[no] = False
            return False

    prim_no[no] = True
    return True

def main():
    prim_vals = {}                         # ????????°?????§????´???°????????°
    while True:
        num = sys.stdin.readline()
        if num is None or num.strip() == '':
            break

        num = int(num.strip())
        if prim_vals.get(num) is not None:
            cnt = prim_vals.get(num)
        else:
            #print('num:', num)
            if num == 1:
                cnt = 0
            else:
                cnt = 0
                #for i in range(3, num + 1, 2):
                if num % 2 == 0:
                    start_num = num -1
                else:
                    start_num = num
                    
                for i in range(start_num, 0, -2):
                    #print('i:', i)
                    if prim_vals.get(i) is not None:
                        cnt += prim_vals.get(i)
                        #cnt -= 1
                        break
                    
                    if is_prime(i):
                        cnt += 1
                        
                #cnt += 1             # 2??????????¶????
                prim_vals[num] = cnt # ????????°?????§????´???°????????°????????????(2?????????)

        print(cnt)

if __name__ == '__main__':
    main()
    #print(prim_no)

Python: def mk_table(n):
    res = [1] * (n + 1)
    res[:2] = 0, 0

    for i in range(2, n):
        if i ** 2 > n:
            break

        if res[i] == 1:
            for j in range(i*2, n + 1, i):
                res[j] = 0

    return res


tbl = mk_table(999999)
try:
    while 1:
        print(len([x for x in tbl[:int(input())+1] if x == 1]))
except Exception:
    pass

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)