Go: package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		flag := false
		count := 0

		for i := 3; i <= num; i += 2 { //1を除く入力値以下の数字
			for j := 3; j < i; j += 2 {
				if i%j == 0 {
					flag = true
					//fmt.Println(i, "/", j)
					break
				}
			}
			if !flag {
				count++
			} else {
				flag = false
			}
		}
		fmt.Println(count + 1)
	}
}

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()

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

LIMIT = 1000000
is_prime = [True] * (LIMIT+1)
p = 2
while p**2 <= LIMIT:
    if is_prime[p]:
        for i in range(p*2, n+1, p):
            is_prime[i] = False
    p += 1

for line in sys.stdin.readlines():
    n = int(line.strip())
    if n <= 1:
        print(0)
        continue
    if n == 2:
        print(1)
        continue
    num_prime = 1
    for i in range(3, n+1):
        if is_prime[i]:
            num_prime += 1
    print(num_prime)

Python: # -*-coding:utf-8
#n??\???????´???°?????°

import fileinput
import math

def main():

    for line in fileinput.input():
        tokens = list(map(int, line.strip().split()))

        primeNumber = tokens[0]
        ans = 1
        for i in range(3, primeNumber+1, 2):
            flag = 0
            for j in range(3, int(math.sqrt(i))+1, 2):
                if(i%j == 0):
                    flag = 1
                    break

            if(flag == 0):
                ans += 1

        print(ans)

if __name__ == '__main__':
    main()

Python: import math
b=[]
b.append(1)
b.append(2)
count=1
s=0
while s<30:
    try:
        x=int(input())
        if x>b[count]:
            for i in range(b[count]+1,x+1):
                count1=0
                
                for j in range(2,int(math.sqrt(i))+1):
                    if i%j==0:
                        count1=1
                        break
                if count1==0:
                    count+=1
                    b.append(i)
            print(count)
        else:
            for i in range(count+1):
                if b[i]>x:
                    print(i-1)
                    break
                elif b[i]==x:
                    print(i)
                    break
        s+=1
    except EOFError:
        break

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))