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
def lb(a,x):
    l=0
    r=len(a)-1
    while l<r:
        mid=int((l+r)/2)
        #print "l=",l,' r=',r
        if a[mid]<x:
            l=mid+1
        else:
            r=mid
    return l

maxn=1000001
a=[False for i in xrange(maxn)]
for i in xrange(2,int(math.sqrt(maxn))):
    for j in xrange(i+i,maxn,i):
        a[j]=True
b=[]
for i in xrange(2,maxn):
    if not a[i]:
        b.append(i)
while True:
    try:
        n=input()
        f=lb(b,n)
        if b[f]==n:
            print(f+1)
        else:
            print(f)
    except EOFError: break

Python: for i in range(30):
	try:
            n = input()
            prime_list = [2]
            i = 3;
            while i<=n :
                judge = True
                for num in prime_list :
                    if(i%num==0) :
                        judge = False
                        break
                if(judge):
                    prime_list.append(i)
                i += 2
            print(len(prime_list))
	except :
		break

Python: from sys import stdin

def prime(n: int) -> int:
    Prime = [i for i in range(n+1)]
    for i in range(2,n+1):
            for j in range(2,int(n/i)+1):
                Prime[i*j] = 0
    Prime[0],Prime[1] = 0,0
    print(Prime)
    ans = [i for i in Prime if not(i == 0)]
    return len(ans)


for line in stdin:
    n = int(line)
    print(prime(n))

Python: import sys


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:
    i = int(i)
    if i == 2:
        print(1)
    elif i == 3:
        print(2)
    else:
        s = 2
        for x in range(2, i + 1):
            if isp(x):
                s += 1
        print(s)

Python: # PrimeNumber
# エラトステネスの篩

from itertools import product
import math

if __name__ == "__main__":
    while True:
        try:
            # 数値の入力があった
            n = int(input())
            nlist = []
            nlist2 = []
            plist = []

            # for i in range(2, n + 1):
            #    nlist.append(i)  # [2,3,4,5,6,...,n]
            nlist = range(3, n + 1, 2)

            while True:
                #print(nlist, " ", math.sqrt(n))
                sqrtn = math.sqrt(n)
                if nlist[0] > sqrtn:  # 終了条件
                    #plist.append(map(int,nlist))
                    plist.extend(nlist)
                    break
                else:
                    plist.append(nlist[0])

                    #i = 0
                    for j in nlist:
                        if j % nlist[0] != 0:
                            #nlist.pop(i)
                            #nlist.remove(j)
                            nlist2.append(j)
                            #i += 1
                    nlist = nlist2
                    nlist2 = []
            #print("fin: {}".format(plist))
            print(len(plist)+1) # 2の分を追加

        except EOFError:
            break  # escape from while loop

pass
#

Python: from math import sqrt
from sys import stdin

def isprime(x) :
    i = 3
    while i <= int(sqrt(x)) + 1 :
        if x % i == 0 : return False
        i = i + 2
    return x

for Input in stdin :
    if int(Input) == 1 : print(0)
    elif int(Input) == 2 : print(1)
    else:
        result = 1
        for make in range(3, int(Input) + 1, 2) :
            if isprime(make) != False : result += 1
        print(result)

Python: a=int(input())
X=[i for i in range(2,a+1)]
Y=[]
while True:
  X=[i for i in X if i % X[0] !=0 ]
  if X == Y:
    break
  Y=X[:]
 
print(len(X))

Python: import sys

def is_prime(x):
	if(x <= 1):
		return 0

	i = 2
	while(i <= x-1):
		if(x % i == 0):
			return 0
		i += 1
	return 1


a = []
i = 0
cnt = 0
for line in sys.stdin:
	a.append(int(line))
	
	cnt = 0
	j = 1
	while(j <= a[i]):
		if(is_prime(j) == 1):
			cnt += 1
		j += 1

	i += 1

	print(cnt)

Python: plst = [1 for i in range(1000001)]
slst = [0,0]
plst[0] = plst[1] = 0
count = 0
for i in range(2,1000001):
  if plst[i] == 1:
    count += 1
    for j in range(i * 2,1000001,i):
      plst[j] = 0
  slst.append(count)
while True:
  try:
    print(slst[int(input())])
  except EOFError:
    break

Python: import sys

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


lst = [i for i in range(2, max(num)+1)]
for i in lst[::-1]:
    for j in range(2, i):
        if i % j == 0:
            lst.pop(lst.index(i))
            break

for i in num:
    for j in lst:
        if i < j:
            print(lst.index(j))
            break
        elif i == j:
            print(lst.index(j)+1)
            break

Python: import numpy
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break
def primesfrom3to(n):
    #?????????n/2??????1byte??????data type = True or False??§??¨???1??§??????
    sieve = numpy.ones(int(n/2), dtype=numpy.bool)
    if n%2 != 0:
        sieve = numpy.append(sieve,n/2)
    #i??????3??????2??????????????????n?????????????????§??????
    for i in range(3,int(n**0.5)+1,2):
        #???????????¶=sieve???True or False??§??¨????????????????????¶??????????????????????´???°?????????????????¶?????\??????
        if sieve[int(i/2)]:
            #????????°???False????????????int(i^2/2)?????????int(i)??????????????§False??????????????????
            sieve[int(i*i/2)::int(i)] = False
    #??????????\???°??????
    return 2*numpy.nonzero(sieve)[0][1::]+1
if __name__ == "__main__":
    array = list(get_input())
    for i in range(int(len(array))):
        primeList = list(primesfrom3to(int(array[i])))
        primeList.insert(0,2)
        #print(primeList)
        print(len(primeList))

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():
    a = []
 
    for line in sys.stdin:
        a.append(int(line))
 
    for line in a:
        print(prime(line))
 
if __name__ == "__main__":
    main()

Python: #!/usr/bin/env python3
import itertools
import math
import sys

MAX = 999999


def sieve_of_eratosthenes(max):
    is_prime = [True] * (max + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(math.sqrt(max)) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * i, max + 1, i):
            is_prime[j] = False
    return filter(lambda x: is_prime[x], range(max + 1))


def main():
    p = list(sieve_of_eratosthenes(MAX))
    for l in sys.stdin:
        n = int(l)
        print(len(list(itertools.takewhile(lambda x: x <= n, p))))


if __name__ == '__main__':
    main()