Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	num := make([]bool, 1000000)

	for sc.Scan() {
		var nmpr int

		n, _ := strconv.Atoi(sc.Text())

		lmt := int(math.Sqrt(float64(n)))

		for i := 2; i <= lmt; i++ {
			for j := 2; i*j <= n; j++ {
				if !num[i*j] {
					num[i*j] = true
				}
			}
		}

		for t := 2; t <= n; t++ {
			if !num[t] {
				nmpr++
			}
		}

		fmt.Println(nmpr)
	}

}

Python: try:
    while True:
        n=int(input())
        nums = range(2, n+1)
        res = list(range(2, n+1))
        for a in nums:
            if a in res:
                tmp = []
                for b in res:
                    if b<=a or b % a != 0:
                        tmp.append(b)
                res = tmp
        print(len(res))
except:
    pass

Python: import sys

primes = [2]
for line in sys.stdin:
  try:
    n = int(line)
    if n > max(primes):
      for i in range(max(primes) + 1, n + 1):
        primes.append(i)
        for p in primes:
          if i % p == 0 and i != p:
            primes.pop()
            break
    ans = [i for i in primes if i <= n]
    print(len(ans))
  except:
    break

Python: def checkPrime(number):
    if number == 2:
        return True
    if number % 2 == 0:
        return False

    i = 3
    while (i ** 2 < number + 1):
        if number % i == 0:
            return False
        i += 2

    return True

p = [True for i in range(0, 1000000)]

p[0] = 0
p[1] = 0
for i in range(2, len(p)):
    p[i] = p[i - 1]
    if checkPrime(i):
        p[i] += 1

while True:
    print(p[int(input())])

Python: from math import sqrt
def p(n):
    l = list(range(2,n+1))
    p = 2
    i = 0
    p = l[i]
    while p < sqrt(n):
        pl = len(l)
        l = list(filter(lambda n: n%p != 0 or n == p,l))
        i += 1
        p = l[i]
    return len(l)

from sys import stdin
for i in stdin:
    print(p(int(i)))

Python: def sieve(n):
    p = [True for i in range(n + 1)]
    p[0] = p[1] = False
    end = int(n ** .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
 
def primes_below(n):
    if n < 2: return 0
    c = 1
    for i in range(3, n + 1, 2):
        if p[i]: c += 1
 
    return c
 
p = sieve(1000000)
while 1:
    try:
        n = int(input())
    except EOFError:
        break
    else:
        print(primes_below(n))

Python: n=int (input())
li=[]
for i in range(2,n+1):
    for j in range(2,i):
        if i%j==0:
            break
    else:
        li.append(i)
print(len(li))

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

import sys


def prime(n):
    s = [i for i in range(2,n+1)]
    p = []
    while s[0] < n**0.5:
        p.append(s[0])
        for ss in s:
            if ss % p[-1] == 0:
                s.remove(ss)
    p.extend(s)
    return p

def main():
    inp = [int(n) for n in sys.stdin]
    for n in inp:
        n_pn = len(prime(n))
        print(n_pn)

if __name__ == '__main__':
    main()

Python: L = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]

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

while 1:
  n=input()
  if not n:break
  print(prime_count(int(n)))

Python: import math

num_max = 999999
i = 3
prime_list = [2]
while i<num_max :
	judge = True
	j = 0
	while prime_list[j] <= math.sqrt(i) :
		if (i%prime_list[j]==0) :
			judge = False
			break
		j += 1
	if(judge) :
		prime_list.append(i)
	i += 2

for i in range(30) :
	try:
		n = input()
		k = 0
		while prime_list[k] <=  n :
			k += 1
		print(k)
	except :
            break

Python: import sys
import math

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

for i in (x for x in range(3,int(math.sqrt(N)),2) if primes[x//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: def main():
    while True:
        try:
            n = int(input())
            a = [True] * (n+1)
            a[0] = a[1] = False
            for i in range(2, int(n**0.5)+1):
                if a[i]:
                    for j in range(i**2, n+1, i):
                        a[j] = False
            print(a.count(True))
        except:
            break

if __name__ == '__main__':
    main()

Python: t = 0
while t == 0:	
	prime = [2,3]
	try:
		n = int(input())
	except:
		break
	#?¨??????\???????????????????¨????
	else:
		if n == 1:
		#1?????????
			print(0)
		elif n == 2:
			print(1)
		elif n <= 4:
			print(2)
		else:
			a = 5
			while a > n:
			#5??\????????????
				total = len(prime)
				#?´???°?????°?????????
				for b in prime:
					if a % b == 0:
						break
						#?´???°??????????????´????????????	
					else:
						if total == 0:
						#?´???°?¢?????????????
							prime.append(a)
						else:
						#?´???°??¢?´¢??°??????
							total -= 1
				if (a + 1) % 6 == 0:
					a += 2
				else:
					a += 5
			print(len(prime))

Python: import sys

a = [True] * 1000000

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

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

Python: import sys
a=[0,0]+[1]*10**6
for i in range(999):
 if a[i]:a[i*2::i]=[0 for j in[0]*len(a[i*2::i])]
for e in sys.stdin:print(sum(a[:int(e)+1]))

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 prime(n):
    for i in range(2, n):
        if n < i ** 2: break
        elif n % i == 0: return False
    return True

[print(len([i for i in range(2, int(x)) if prime(i)])) for x in sys.stdin]

Python: from sys import stdin

for Input in stdin :
    Input = int(Input)
    if (Input <= 10) : 
        if   (Input <= 1) : print(0)
        elif (Input == 2) : print(1)
        elif (Input == 3) or (Input == 4) : print(2)
        elif (Input == 5) or (Input == 6) : print(3)
        else : print(4)
    else :
        result = 4
        for make in range(11, Input + 1, 2) :
            if (make % 2 != 0) and (make % 3 != 0) and (make % 5 != 0) and (make % 7 != 0) : result += 1
        print(result)