Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var primeCount int
	for sc.Scan() {
		input := nextInt()
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		fmt.Printf("%d\n", primeCount)
		primeCount = 0
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2:
		return true
	case num < 2 || num%2 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

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

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

Python: import math

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

        for i in range(2, n+1):
            cnt = 0
            
            for j in range(2,i):
                if i % j == 0:
                    cnt = cnt + 1
                    break
                    
            if cnt == 0:
                #?´???°
                prime_cnt = prime_cnt + 1
                

        print(str(prime_cnt))
    except:
        break

Python: import sys
  
f = [0, 1] * 500000
f.append(0)
f[1] = 0
f[2] = 1
i = 3
while i < 1000:
    if f[i] == 1:
        j = i * i
        while j <= 1000000:
            f[j] = 0
            j += i + i
    i += 2

for n in sys.stdin:
    i = int(n)
    print(sum(f[:i + 1]))

Python: import sys

for input in sys.stdin:
    prime_num = 0
    for i in xrange(int(input)):
        y = i+1
        x = y / 2
        for i in xrange(x):
            r= i+1
            if r == 1:continue
            if y % r == 0:
                break
        else:
            prime_num += 1
    print(prime_num-1)

Python: import sys
 
primes = [1] * 500000
primes[0] = 0
 
for i in range(3, 1000, 2):
    if primes[i // 2]:
        primes[(i * i) // 2::i] = [0] * len(primes[(i * i) // 2::i])
 
for i in sys.stdin:
    n = int(i)
    if n < 4:
        print(n - 1)
    else:
        print(sum(primes[:(n + 1) // 2]) + 1)

Python: N=1000000
n=int(N**0.5)
prime=[True for i in range(N)]
prime[0],prime[1]=False,False
for i in range(4,N,2):
    prime[i]=False
for i in range(3,n,2):
    if prime[i]==True:
        for j in range(i*2,N,i):
            prime[j]=False
prime_number=[i for i,j in enumerate(prime) if j==True]
while 1:
    try:
        number=int(input())
        count=0
        for i in prime_number:
            if number<i:break
            else:count +=1
        print(count)
    except:break

Python: import sys
def main():
    for _ in range(30):
        try:
            number = int(sys.stdin)
        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: import sys

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

if __name__ == '__main__':
    for line in sys.stdin:
        ko=0
        n = int(line)
        for i in range(0,n+1):
            if sosu(i):
                ko+=1
        print(ko)

Python: def PrimeNumber(num,summation):
    for i in range(1,num+1):
        n=0
        for j in range(1,i):
            if i%j==0:
                n+=1
        if n==1:
            summation+=1
    return summation
    
while True:
    try:
        num=int(input())
    except:
        break
    print(PrimeNumber(num,0))

Python: prime=[True]*1000000
for i in range(2,1000):
    if prime[i]:
        for j in range(i*2,1000000,i):
            prime[j]=False

while True:
    try:
        n=int(input())
    except:
        break
    print(sum(prime[2:n+1]))

Python: lst = [1]*999999
for i in range(999999):
    if i == 0:
        lst[i] = 0
    else:
        if lst[i] == 1:
            j = i +1
            k = i
            while True:
                k = k + j
                if k >= 999999:
                    break
                        
                lst[k] = 0

while True:
    try:
        n = int(input())
        anslst = lst[:n]
        print(sum(anslst))
        

    except EOFError:
        break

Python: # nまでの自然数が素数かどうかを表すリストを返す
# Sieve of Eratosthenes
def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if isPrime[i]:
            for j in range(i * i, n + 1, i):
                isPrime[j] = False
    return isPrime

ls = makePrimeChecker(10**6)

ls_ans = []
while True:
    try:
        n = int(input())
        ls_ans.append(sum(ls[:n+1]))
    except:
        break

for i in range(len(ls_ans)):
    print(ls_ans[i])

Python: while True:
    try:
        Num = 1
        n = int(input())
        for i in range(2,n+1):
            for j in range(2,i):
                if i % j == 0:
                    break
                if j == i-1:
                    Num +=1
        print(Num)           
    except EOFError:
        break

Python: import math
import sys

sup = 1000000

is_prime = [0] * sup

count = [0] * sup

def setup():
    is_prime[2] = 1
    for n in range(3,sup,2):
        flag = True
        for i in range(3, int(math.floor(math.sqrt(n) + 1)), 2):
            if n % i == 0:
                flag = False
                break
        if flag:
            is_prime[n] = 1

def precount():
    for n in range(2, sup):
        count[n] = count[n-1] + is_prime[n]

def main():
    setup()
    precount()

    l = []

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

    for line in l:
         print(count[line])

if __name__ == "__main__":
    main()

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

def cntPrime(n):
    mx = sqrt(n) + 1
    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, floor(n/c) + 1, 1):
            l[c * k -1] = 0
        c = l[:c].index(1) + c
        while c % 2 == 0: 
            c = l[:c].index(1) + c
    return sum(l)
for n in stdin:
    n = int(n)
    print(cntPrime(n))

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

Python: def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break
if __name__ == '__main__':
    array = list(get_input())
    cnt,flag = 0,0
    for i in range(len(array)):#?????°????????°????????????
        for j in range(2,int(array[i])+1):#1??????????´??????¢??????????´???°??¢?´¢????????????
            flag = 0
            if j == 2:
                flag = 1
            for k in range(2,j):
                if j % k == 0:
                    flag = 0
                    break
                flag = 1
            if flag == 1:
                cnt += 1  
        print(cnt)
        cnt = 0

Python: import sys

ary=[]
for i in sys.stdin:
    ary.append(int(i))

def isp(n):
    a = 1
    for i in range(2, int(n ** 0.5) + 1):
        if not n % i:
            a = 0
            break
    return a

for m in ary:
    s = 0
    for i in range(2, m+1):
        if isp(i):
            s += 1
    print(s)