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 = []
ns = sys.stdin.readlines()
for n in ns:
    N.append(int(n))
ml = max(N)
P = [2]
for x in range(2, ml+1):
    flag = True
    for d in P:
        flag = flag and (x % d != 0)
    if flag == True:
        P = P + [x]
for m in N:
    print(len([p for p in P if p<=m]))

Python: from math import sqrt,floor
from sys import stdin

def cntPrime(n):
    mx = sqrt(n) + 1
    l = [0] + [1] * (n - 1)
    c = 2
    while c < mx:

        for k in range(2, floor(n/c) + 1):
            l[c * k -1] = 0
        c = l[:c].index(1) + c
    return sum(l)
for n in stdin:
    n = int(n)
    print(cntPrime(n))

Python: from math import sqrt,floor
from sys import stdin

def cntPrime(n):
    mx = sqrt(n)
    if n % 2 == 0:
      l = [0, 1] + [1, 0] * (int(n/2) - 1)
    else:
      l = [0, 1] + [1, 0] * (int(n/2) - 1) + [1]
    c = 3
    while c < mx:
        for k in range(c*2, n+1, c):
            l[k-1] = 0
        c = l[(c+1):].index(1) + c +2
        while c % 2 == 0:
            c = l[(c+1):].index(1) + c +2
    return l
t = cntPrime(1000000)
for n in stdin:
    n = int(n)
    print(sum(t[:n-1]))

Python: import bisect
import sys
n = 1000000
primes = {i for i in range(3, n, 2)}
for i in range(3, 1000, 2):
    s = {j for j in range(i*2, n, i)}
    primes -= s

primes = [2] + sorted(primes)
for l in sys.stdin:
    print(bisect.bisect(primes, int(l)))

Python: import sys
import math
#from me.io import dup_file_stdin

primes = [2,3,5,7]

def isPrime(x):
    if x<=primes[-1]:
        return x in primes
    else:
        for prime in primes:
            if x%prime==0:
                return False
        else:
            current=primes[-1]
            dst=math.sqrt(x)
            while current<dst:
                if(x%current==0):
                    return False
            else:
                return True

#@dup_file_stdin
def solve():
    for query in map(int,sys.stdin):
        if(query>primes[-1]):
            for i in range(primes[-1]+1,query+1):
                if isPrime(i):
                    primes.append(i);
        print(len([x for x in primes if x<=query]))
solve()

Python: import math

a = [1]*1000000
for i in range(2,1000000):
    for j in range(i+i,1000000)[::i]:
        a[j] = 0

b = [0]*1000000
b[0] = b[1] = 0
for i in range(2,1000000):
    if a[i] == 1:
        b[i] = b[i-1] + 1
    else:
        b[i] = b[i-1]

while True:
    try:
        print(b[int(input())])
    except EOFError:
        break

Python: import sys
pr = [1]*1000000
pr[0] = 0
pr[1] = 0
for i in range(2,int(len(pr)/2)+1):
	if pr[i]==1:
		j = i*2
		while j < int(len(pr)/2)+1:
			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 sys

input_list = list(int(i) for i in sys.stdin)
max_n = min(1000000, max(input_list) + 1)

prime_list = list(i % 2 for i in range(max_n))
prime_list[1], prime_list[2] = 0, 1
i = 3
while i * i < max_n:
    if prime_list[i]:
        for j in range(i * 2, max_n, i):
            prime_list[j] = 0
    i += 2

for i in range(1, max_n):
    prime_list[i] += prime_list[i - 1]

inset = sorted((n, i) for i, n in enumerate(input_list))
outset = sorted((t[1], prime_list[t[0]]) for t in inset)
for t in outset:
    print(t[1])

Python: while True:
    try:
        n = int(input())
        nums = list(range(n + 1))
        nums[1] = 0
        for i in range(n):
            if nums[i] > n ** 0.5:
                break
            if nums[i] == 0:
                continue
            for j in range(nums[i] * 2, n + 1, nums[i]):
                nums[j] = 0
        print(n + 1 - nums.count(0))
    except:
        break

Python: import sys

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

def prime(n):
    cnt = 0
    for i in range(0, n+1):
        ans = prime_calc(i)
        if ans is True:
            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: 
def isp(n):
    a = 1
    for i in range(2, (n + 1) // 2 + 2):
        if not n % i:
            a = 0
            break
    return a


for i in sys.stdin:
    n = int(i)
    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 prime_number(n):
    cache = {2} 
    a = 2 
    while a <= n:
        if n < 2:
            cache = {}
            break
        if not a in cache:
            if not [x for x in cache if a % x == 0]: 
                cache.add(a)
        a+=1
    print(len(cache))

try:
    while True:
        n=int(input())
        prime_number(n)
except:
    pass

Python: limit = int(input(""))
arr = [2,3,5,7]
def PrimeNumber(arr,number):
    for i in arr:
        if (number%i==0):
            return False
    return True

for i in range(2,limit+1):
    if(PrimeNumber(arr,i)):
        arr.append(i)
        
count = 0
for i in arr:
    if (i>limit):
        break
    else:
        count += 1
    

print(count)

Python: import math
import sys

MAX_V = 999999
prime = [1] * (MAX_V+1)
prime[0], prime[1] = [0, 0]
sum = [0] * (MAX_V+2)

for i in range(2, math.ceil(math.sqrt(MAX_V))+1):
    if prime[i]:
        for k in range(2*i, MAX_V+1, i):
            prime[k] = 0
for i in range(MAX_V+1):
    sum[i+1] = sum[i] + prime[i]
for line in sys.stdin.readlines():
    print(sum[int(line)+1])

Python: import sys
pr = [1]*1000000
pr[0] = 0
pr[1] = 0
for i in range(2,int(len(pr)/2)):
	if pr[i]==1:
		j = i*2
		while j < int(len(pr)/2):
			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: 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:
  print(prime_count(int(input())))