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

primes = [2, 3]
for n in range(5, 999999, 2):
    isprime = True
    for i in range(len(primes)):
        if primes[i]**2 > n:
            break
        if n%primes[i] == 0:
            isprime = False
            break
    if isprime:
        primes.append(n)

numbers = []
count = 0
for line in sys.stdin:
    numbers.append(int(line))
    count += 1

counts = []
for i in range(count):
    counts.append(0)

for prime in primes:
    if prime > 999999:
        break
    for i in range(count):
        if prime <= numbers[i]:
            counts[i] += 1

for count in counts:
    print(count)

Python: def main():
    for _ in range(30):
        try:
            number = int(input())
        except EOFError:
            return None
        p = 0
        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: # sieve of Eratosthenes
N = 1000000
isprimer = [True for i in range(N)]
isprimer[0], isprimer[1] = False, False
for i in range(2, N):
	if not isprimer[i]:
		continue
	for j in range(i * 2, N, i):
		isprimer[j] = False

while True:
	try:
		num = eval(input())
		count = 0
		for i in range(2, num + 1):
			if isprimer[i]:
				count += 1
		print(count)
	except EOFError:
		break

Python: import sys
 
 
xx = 500000
f = [0, 1] * xx
 
i = 3
while i * i <= 2 * xx:
    if f[i] == 1:
        j = i * i
        while j <= 2 * xx:
            f[j] = 0
            j += i + i
    i += 2
 
f.pop(0)
f.pop(1)
 
for n in sys.stdin:
    i = int(n)
    if i < 2:
        print(0)
    else:
        print(sum(f[:i - 1]))

Python: import sys
def isPrime(i):
    if i<2:
        return False
    else:
        for j in range(2,i):
            if j*j>n:
                break
            elif i%j==0:
                return False
        return True

def countPrime(i):
    cnt=0
    for x in range(2,i+1):
        if isPrime(x) == True:
            print(x)
            cnt+=1
    return cnt

while True:
    try:
        n=int(input())
        cnt=0
        for x in range(2,n+1):
            if isPrime(x)==True:
                cnt+=1
        print(cnt)
    except:
        break

Python: # coding=utf-8
import array


def sieve_of_eratosthenes(end: int) -> array:
    # noinspection PyUnusedLocal
    is_prime = array.array('B', (True for i in range(end+1)))
    is_prime[0] = False
    is_prime[1] = False

    primes = array.array("L")
    for i in range(2, end+1):
        if is_prime[i]:
            primes.append(i)
            for j in range(i * 2, end+1, i):
                is_prime[j] = False
    return primes


if __name__ == '__main__':
    prime_table = sieve_of_eratosthenes(1000000)
    while True:
        try:
            n = int(input())
        except EOFError:
            break
        prime_table_under_n = [x for x in prime_table if x <= n]
        print(len(prime_table_under_n))

Python: def p(n):
    l = list(range(2,n+1))
    p = 2
    i = 0
    p = l[i]
    while True:
        pl = len(l)
        l = list(filter(lambda n: n%p != 0 or n == p,l))
        i += 1
        p = l[i]
        if pl == len(l):
            break
    return len(l)

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

Python: import math

def yo(n):
    if n==1:    return False
    s=2
    while s <= int(math.sqrt(n)):
        if n%s == 0:    return False
        s+=1
    return True

while True:
    c=0
    try:
        for i in range(1, int(input())+1):
            if yo(i)==True:    c+=1
        print(c)
    except:
        break

Python: import math

while(1):
    try:
        n = int(input())
    except:
        break

    m = int(math.sqrt(n))
    keys = [n // i for i in range(1, m+1)]
    keys += range(keys[-1]-1, 0, -1)
    h = {i: i-1 for i in keys}

    for i in range(2, m+1):
        if h[i] > h[i-1]:
            hp = h[i-1]
            i2 = i*i
            for j in keys:
                if j < i2:
                    break
                h[j] -= h[j // i] - hp
    print(h[n])

Python: from math import sqrt
cash = {}
def isprime(n):
    if n in cash:
        return cash[n]
    if n == 1:
        return 0
    if n == 2:
        return 1
    if n % 2 == 0:
        return 0
    for i in range(2,int(sqrt(n)+1)):
        if n % i == 0:
            return 0
    cash[n] = 1
    return 1

from sys import stdin
h = {}
for i in stdin:
    i = int(i)
    c = sum(isprime(n) for n in range(2,i+1))
    print(c)

Python: import sys

values = []
for line in sys.stdin:
    if 1000000 > int(line):
        values.append(line)

for val in values:
    prime = 0
    for i in range(2, val // 2):
        if val % i != 0:
            prime += 1
    print(prime)

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

Python: while 1:
    try:
        count=0;
        x=int(input())
        if x==1:
            print(0)
        elif x==2:
            print(1)
        else:
            a=[int(i) for i in range(2,x+1)]
            for i in  range(len(a)):
                count1=0
                for j in range(2,a[i]):
                    if a[i]%j==0:
                        count1+=1
                if count1==0:
                    count+=1
            print(count)        
    except EOFError:
        break

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

lines = str(sys.stdin.read()).strip().split("\n")

for line in lines:
    line = int(line)
    pList = []
    sList = list(reversed(list(range(3, line + 1))[::2]))
    while sList[-1] < int(math.ceil(math.sqrt(line))) + 1 :
        pList.append(sList.pop())
        for p in pList:
            sList = list(filter(lambda i: i % p != 0, sList))
    pList.extend(sList)
    pList.append(2)
    print(len(pList))

Python: import sys
import math
M = 1000000
B = int(math.sqrt(M)+1)
N = M//6
N1 = N+1 if M % 6 == 5 else N
N2 = N+1 if M % 6 >= 1 else N
l = [1] * N1
m = [1] * N2
for i in range(5,B,6):
    p = (i-5)//6
    ini = (i*5-1)//6
    if l[p] == 1:
        l[p+i::i] = [0] * len(l[p+i::i])
        m[ini-1::i] = [0] * len(m[ini-1::i])
    if m[p] == 1:
        m[p+i+2::i+2] = [0] * len(m[p+i+2::i+2])
        l[ini+1::i+2] = [0] * len(l[ini+1::i+2])

for i in sys.stdin:
    n = int(i)
    r =  n-1 if n < 4 else sum(l[0:(n+1)//6])+sum(m[0:(n-1)//6])+2
    print(r)

Python: while True:
    try:
        n=int(input())
    except:
        break
    print(sum(i==2 or pow(2,i-1,i)==1 for i in range(2,n+1)))