Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

func isPrime(n int) bool {
	for i := 2; i*i <= n; i++ {
		if n % i == 0 {
			return false
		}
	}
	return true
}

func main() {
	for scanner.Scan() {
		n := nextInt()
		cnt := 0
		for i := 2; i <= n; i++ {
			if isPrime(i) {
				cnt++
			}
		}
		fmt.Println(cnt)
	}
}

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

Python: #init
max_num = 1000000
is_prime_num = [True for i in range (max_num+1)]

#0, 1 --- not prime number
is_prime_num[0] = False
is_prime_num[1] = False
end = int(max_num ** .5)

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


while True:
    try:
        n = int(input())
        prime_cnt = 0
        for i in range(1, n+1):
            if is_prime_num[i]:
                prime_cnt = prime_cnt + 1
                   
   
        print(str(prime_cnt))
    except:
        break

Python: import sys

prime = [2,3,5,7,11,13,19,23,29,31]

shieve1 = [1]*1001
for i in prime:
    itr = i-1
    while(itr<1000):
        shieve1[itr] = 0
        itr += i

for i in range(32,1000):
    if shieve1[i]:
        prime.append(i+1)

shieve2 = [1]*(10**6+1)

for i in prime:
    itr = i-1
    while(itr<10**6):
        shieve2[itr] = 0
        itr += i

for i in range(1001,10**6+1):
    if shieve2[i]:
        prime.append(i+1)

for line in sys.stdin:
    n = int(line)
    cont = 0
    for i in prime:
        if i<=n:
            cont += 1
        else:
            break
    print(cont)

Python: # Aizu Problem 0009: Prime Number
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def primes2(n):
    """ Input n>=6, Returns a list of primes, 2 <= p < n """
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1,int(n**0.5)//3+1):
      if sieve[i]:
        k=3*i+1|1
        sieve[      k*k//3      ::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
        sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]

primes = primes2(10**6)

for line in sys.stdin:
    n = int(line)
    idx = bisect.bisect_right(primes, n)
    print(idx)

Python: import sys
import math
pr = [1]*1000000
pr[0] = 0
pr[1] = 0
maxval = math.ceil(math.sqrt(999999))
for i in range(2,maxval):
	if pr[i]==1:
		j = i*2
		while j < maxval:
			pr[j] = 0
			j += i

for line in sys.stdin:
	n = int(line)
	cnt = 0
	for i in range(n+1):
		if pr[i]==1:
			cnt += 1
	print(cnt)

Python: import math
import sys

def prime_calc(n):
    rootN = math.floor(math.sqrt(n))
    prime = [2]
    data = [i + 1 for i in range(2,n,2)]
    while True:
        p = data[0]
        if rootN <= p:
            return len(prime + data)
        prime.append(p)
        data = [e for e in data if e % p != 0]

def main():
    l = []

    for line in sys.stdin:
        l.append(line)        

    for line in l:
        print(prime_calc(line))

if __name__ == "__main__":
    main()