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

N = 1000000
lst = [1] * N
for i in range(3, int(N**0.5), 2):
    if lst[i]:
        lst[i*i::2*i] = [0] * len(lst[i*i::2*i])
lst = [2] + [i for i in range(3, N, 2) if lst[i]]
for i in sys.stdin:
    for j in range(len(lst)):
        if lst[j] > int(i):
            print(j)
            break

Python: import sys, math

class Eratos(object):
    def __init__(self, N):
        self.N = N
        self._primes = {i:True for i in range(2, N+1)}

    def filter(self):
        end = self.N
        if self.N > 5:
            end = math.ceil(self.N**0.5) + 1
        for n in range(2, end):
            if not self._primes[n]:
                continue
            for x in range(n*2, self.N+1, n):
                if x in self._primes:
                    self._primes[x] = False
    
    def primes(self, x):
        return [k for k,v in self._primes.items() if v == True and k <= x]

def run():
    e = Eratos(999999)
    e.filter()
    for _n in sys.stdin:
        N = int(_n)
        print(len(e.primes(N)))

if __name__ == '__main__':
    run()

Python: import sys

num_of_data = 0

while True:
    if num_of_data >= 30:
        break
    try: 
        n = int(input())
        if n >= 1 and n <= 999999:
            cnt = 0
            for i in range(1, n+1):
                flag = 0
                for j in range(1, i+1):
                    if i%j == 0:
                        flag += 1
                if flag == 2:
                    cnt += 1

            print(cnt)
            num_of_data += 1
    
    except EOFError:
        sys.exit()

Python: import sys;
import math;

lines = str(sys.stdin.read()).strip().split("\n")

for line in lines:
    line = int(line)
    pList = []
    sList = list(reversed(list(range(3, line + 1))[::2]))
    while sList[-1] < math.ceil(math.sqrt(line)) + 1 :
        pList.append(sList.pop())
        for p in pList:
            sList = list(filter(lambda i: i % p != 0, sList))
    print(len(sList) + len(pList) + 1)

Python: import sys,random

rand = random.randint

def prime(n):
	if n == 2:
		return True
	if n < 2 or n & 1 == 0:
		return False
	d = (n-1) >> 1
	while d & 1 == 0:
		d >>= 1
	
	for i in range(2):
		a = rand(1,n-1)
		t = d
		y = pow(a,t,n)
		while t != n-1 and y != 1 and y != n-1:
			y = pow(y,2,n)
			t <<= 1
		if y != n-1 and t & 1 == 0:
			return False
	return True

a = [prime(i) for i in range(1000000)]

for s in sys.stdin:
	i = int(s)
	print(a[:i+1].count(True))

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):
            if yo(i)==True:    c+=1
        print(c)
    except:
        break

Python: import sys

def prime_calc(n):
    if n < 2:
        return 0
    else:
        i = 2
        while i*i <= n:
            if n % i == 0:
                return 0
            else:
                i = i + 1

    return 1

def prime(n):
    cnt = 0
    for i in range(1, n+1):
        ans = prime_calc(i)
        if ans == 1:
           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: import sys
def isprime(num):
   i = 2
   count = 0
   while i< num:
       if num % i == 0:
           count += 1
       i += 1
   if count == 0:
       return 1
   else:
       return 0
for line in sys.stdin:
   num = int(input())
   count_prime = 0
   for i in range(2,num+1):
       if(isprime(i) == 1):
           count_prime += 1
   print(count_prime)
else:
   exit()

Python: def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
t=0
while t == 0:
    try:
        x = int(input())
    except:
        break
    else:
        n = 1
        if x == 0 or 1:
            print(0)
        elif x == 2:
            print(1)
        else:
            for i in range(0,x + 1,2):
                if is_prime(i):
                    n += 1
            print(n)

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=[int(i) for i in input().split(" ")]
    except:break
    a=raw[0]
    print(str(ct(a)))

Python: from collections import deque
import bisect
from math import sqrt
import sys
primes = deque([2, 3, 5, 7, 11, 13, 17, 19])
append = primes.append
for i in range(21, 1000000, 2):
    for j in range(3, int(sqrt(i))+1, 2):
        if i%j == 0:
            break
    else:
        append(i)

for l in sys.stdin:
    print(bisect.bisect(primes, int(l)))

Python: import sys

N = 1000000
lst = [1] * N
for i in range(3, int(N**0.5)+1, 2):
    if lst[i] == 1:
        lst[i*i::2*i] = [0] * len(lst[i*i::2*i])
lst = [2] + [i for i in range(3, N, 2) if lst[i] == 1]
for i in sys.stdin:
    for j in range(len(lst)):
        if lst[j] > int(i):
            print(j)
            break

Python: import math

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

        for i in range(2, n+1):
            cnt = 0
            
            for j in range(2,i):
                if i % j == 0:
                    cnt = cnt + 1
                    break
                    
            if cnt == 0:
                #?´???°
                prime_cnt = prime_cnt + 1
                

        print(str(prime_cnt))
    except:
        break

Python: import sys
  
f = [0, 1] * 500000
f.append(0)
f[1] = 0
f[2] = 1
i = 3
while i < 1000:
    if f[i] == 1:
        j = i * i
        while j <= 1000000:
            f[j] = 0
            j += i + i
    i += 2

for n in sys.stdin:
    i = int(n)
    print(sum(f[:i + 1]))

Python: import sys

for input in sys.stdin:
    prime_num = 0
    for i in xrange(int(input)):
        y = i+1
        x = y / 2
        for i in xrange(x):
            r= i+1
            if r == 1:continue
            if y % r == 0:
                break
        else:
            prime_num += 1
    print(prime_num-1)

Python: import sys
 
primes = [1] * 500000
primes[0] = 0
 
for i in range(3, 1000, 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 < 4:
        print(n - 1)
    else:
        print(sum(primes[:(n + 1) // 2]) + 1)