Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var primeCount int
	for sc.Scan() {
		input := nextInt()
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		fmt.Printf("%d\n", primeCount)
		primeCount = 0
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2:
		return true
	case num < 2 || num%2 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

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

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

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(len(multiple_list + serial_number_list))

Python: import sys
from math import sqrt

for line in sys.stdin:
    n = int(line.strip())
    L, pn, tmp = int(sqrt(n)), [], [i for i in range(2, n+1)]
    while tmp[0] < L+1:
        v = tmp.pop(0)
        pn.append(v)
        tmp = list(filter(lambda x: x%v!=0, tmp))
    for t in tmp: pn.append(t)
    print(len(pn))

Python: l = [1 for i in range(10 ** 6 + 1)]
l[0] = l[1] = 0
for i in range(10 ** 6 + 1):
  if l[i] == 1:
    for j in range(i * 2, 10 ** 6 + 1, i):
      l[j] = 0
while 0 == 0:
  try:
    n = int(input())
    c = 0
    for i in range(n + 1):
      c += l[i]
    print(c)
  except EOFError:
    break

Python: import math
import sys

a = [1]*10000000
a[0] = a[1] = 0

for i in range(2,int(math.sqrt(2000000))):
    if a[i] == 1:
        for j in range(i+i,2000000,i):
            a[j] = 0

for i in range(1,2000000):
    a[i] += a[i-1]
    
for line in sys.stdin:
    print(a[int(line)])

Python: import sys
import math as mas

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
	
sosu=sieve(1000010)
for i in sys.stdin:
	print(sum(sosu[t] for t in range(int(i))))

#	a,b=map(int,i.split())
#	print(gcd(a,b),lcm(a,b))

Python: # the sieve of Eratosthenes
primes = [1] * 1000000
primes[0] = 0
primes[1] = 0
for i in range(2, 1000):
    if primes[i]:
        primes[i*2::i] = [0] * len(primes[i*2::i])

from itertools import accumulate
acc_primes = list(accumulate(primes))

for i in range(30):
    try:
        n = int(input())
        print(acc_primes[n])
    except EOFError:
        break

Python: import sys

MAX = 999999

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

L = prime_list(int(MAX**0.5))

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

L2 = prime_list(MAX)

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

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

Python: import math
n = 1000001
rn = round(math.sqrt(n)) + 1
tbl = [True for i in range(n)]
tbl[0], tbl[1] = False,False
for i in range(4,n,2):
    tbl[i] = False
for i in range(3,rn,2):
    if tbl[i]:
        for j in range(i*2,n,i):
            tbl[j] = False
n = int(input())
while 1:
    print(sum(tbl[:n+1]))
    try: n = int(input())
    except EOFError:break