Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		input := nextInt()
		fmt.Println(IsPrime(input))
	}
}

func IsPrime(num int) int {
	eratos := make([]bool, num+1)
	c := 0
	for i := 2; i < len(eratos); i++ {
		if eratos[i] == false {
			c++
			eratosCalc(i, eratos)
		}
	}
	return c
}

func eratosCalc(primeNum int, eratos []bool) {
	for i := primeNum * primeNum; i < len(eratos); i += primeNum {
		eratos[i] = true
	}
}

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

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

Python: import sys

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

for e in sys.stdin:
    n = int(e)
    print(len(primes(n)))

Python: import argparser

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 = []
    
    parser = argparse.ArgumentParser()
    parser.add_argument("filename", help="The filename to be processed")
    args = parser.parse_args()

    if args.filename:
        with open(args.filename) as f:
            for line in f:
                a = int(line.rstrip())
                l.append(a)


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

if __name__ == "__main__":
    main()

Python: import math

def prime_judge(n):
    if n==1:
        return False
    elif n==2:
        return True
    elif n%2==0:
        return False
    else:
        sqrt_num=math.ceil(math.sqrt(n))+1
        for i in range(3,sqrt_num, 2):
            if n%i==0:
                return False
        return True

def prime_count(n):
    count=0
    for i in range(1,n+1):
        if prime_judge(i):
            count+=1
    print(count)

while 1:
    try:
        prime_count(int(input()))        
    except EOFError:
        break

Python: def pri(s,n): 
    tab=[i for i in range(n+1) if s[i] and i>=2]
    return(tab)
 
s=[True for _ in range(999999+1)]
i=2
while i**2<=999999:
    if s[i]:
        j=i*2
        while j<=999999:
            s[j]=False
            j+=i
    i+=1

while True:
    try:
        print(len(pri(s,int(input()))))
    except:
        break

Python: LIMIT = 10000000
 
isPrime = [True for _ in range(LIMIT)]

isPrime[0] = isPrime[1] = False
 
for i in range(2, int(LIMIT ** 0.5)+1):
  if isPrime[i]:
    for j in range(i * i, LIMIT, i):
      isPrime[j] = False
 
try:
    while True:
        n = int(input())
        count = 1 if isPrime[2] else 0
        for i in range(3, n+1, 2):
            if isPrime[i]:
                count += 1
        print(count)
except EOFError:
  pass

Python: import sys
m=166666;s=[1]*m;t=[1]*m
for i in range(m):
 for j in range(2):
  if (s[i],t[i])[j]:
   k=6*i+[5,7][j];n=[i+k,k-i-2]
   s[n[j]::k]=[0]*len(s[n[j]::k])
   t[n[1-j]::k]=[0]*len(t[n[1-j]::k])
for e in map(int,sys.stdin):
 print([e-1,sum(s[:(e+1)//6])+sum(t[:(e-1)//6])+2][e>3])

Python: def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass
    
if __name__ == '__main__':

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

            ans = primes(n)
            print(len(ans))
            
        except EOFError:
            break

Python: import sys
n = [int(line) for line in sys.stdin]

prime = [0, 0] + [1] * (max(n) - 1)

for i in range(len(prime)):
    if prime[i]:
        for j in range(2 * i, len(prime), i):
            prime[j] = 0

for i in range(1, len(prime)):
    prime[i] += prime[i - 1]

for ni in n:
    print(prime[ni])

Python: while True:
    n = int(input())
    is_prime = [True for i in range(n + 1)]
    is_prime[0] = False
    is_prime[1] = False

    p = 0

    for i in range(2, n + 1):
        if is_prime[i]:
            p += 1
            for j in range(i * 2, n + 1, i):
                is_prime[j] = False

    print(p)

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 a[i*2::i]]
for e in sys.stdin:print(int(e)-len([i for i in li[:int(e)+1]if i]))

Python: import sys

def prime(n):
	if n == 2: return True
	if n < 2 or n & 1 == 0: return False
	return pow(2, n-1, n) == 1

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

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

Python: import sys
m=500000;a=[1]*m
for i in range(3,999,2):
 if a[i//2]:a[i*i//2::i]=[0]*((m-1-i*i//2)//i+1)
for e in map(int,sys.stdin):print([e-1,sum(a[:(e+1)//2])][e>3])

Python: import sys
a=[1]*500000
for i in range(3,999,2):
 if a[i//2]:a[(i*i)//2::i]=[0]*len(a[(i*i)//2::i])
for e in map(int,sys.stdin):print([e-1,sum(a[:(e+1)//2])][e>3])

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: def prime_checker(n, option = False) -> list:
    p = [False, True, False, False, False, True] * (n // 6 + 1)
    del p[n + 1:]
    p[1 : 4] = False, True, True
    for x in range(5, int(n**.5 + 1)):
        if p[x]:
            p[x * x :: 2*x] = [False] * ((n // x - x) // 2 + 1)
    return [e for e, q in enumerate(p) if q] if option else p

from itertools import accumulate
*c, = map(int, open(0))
*p, = accumulate(prime_checker(max(c)))
for i in c:
    print(p[i])

Python: #!/usr/bin/env python
# -*- coding: utf-8 -*-


def sieve(ks):
    rejected_set = {x for x in ks for i in range(
        1, x) for j in range(i, x) if i + j + 2 * i * j == x}
    return {2} | {2 * y + 1 for y in (ks - rejected_set)}


def number_of_primes(n):
    return len({p for p in sieve(set(range(1, n + 1))) if p <= n})


def main():
    raw_args = []
    while True:
        try:
            raw_args.append(input())
        except EOFError as e:
            break
    for n in map(int, raw_args):
        print(number_of_primes(n))

if __name__ == "__main__":
    main()

Python: def isprime(x):
    if x == 2:
        return True
    elif x < 2 or x%2 == 0:
        return False
    i = 3
    while i <= pow(x,1/2):
        if x%i == 0:
            return False
        i = i + 2
    return True
import sys
import itertools as it
line = sys.stdin.readlines()
for n in line:
    n = int(n)
    if n == 2:
        print(1)
    else:
        count = 1
        for s in range(3,n+1,2):
            if isprime(s):
                count += 1
    print(count)

Python: from math import sqrt
n = 1000000
l = [1]*n
c = [0]*n
d = 0
l[1]= l[0] = 0
for i in range(4,n,2):
    l[i] = 0
for i in range(9,n,2):
    for j in range(3,int(sqrt(i))+1,2):
        if i % j == 0:
            l[i] = 0
            break
for i in range(n):
    if l[i] == 1:
        d += 1
    c[i] = d
while True:
    try:
        n = int(input())
        print(c[n])
    except:
        exit()