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

Python: import sys
import math

# Sieve of Eratosthenes
N = 999999
searchList = list(range(3, N + 1, 2))
primes = [2]
while True:
  top = searchList.pop(0)
  primes.append(top)
  if top > math.sqrt(N):
    break
  searchList = [s for s in searchList if s % top != 0]
primes.extend(searchList)

# solve
for line in sys.stdin:
  try:
    n = int(line)
    ans = [i for i in primes if i <= n]
    print(len(ans))
  except:
    break

Python: prime=[True]*1000000
np=[0]*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: def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

MAX = 1000000
primes = list()
for i in range(MAX):
    primes.append(True)
primes[0] = False
primes[1] = False

for i in range(2, MAX):
    j = i + i
    while j < MAX:
        primes[j] = False
        j = j + i

N = list(get_input())
for l in range(len(N)):
    n = int(N[l])
    ans = 0
    for i in range(n+1):
        if primes[i]:
            ans = ans + 1
    print(ans)

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(len([i for i in li[:int(e)+1]if i]))

Python: import math
import sys

def prime_calc(n):
    rootN = math.floor(math.sqrt(n))
    prime = [2]
    data = [i + 1 for i in range(2,n,2)]
    while True:
        p = data[0]
        if rootN <= p:
            return len(prime + data)
        prime.append(p)
        data = [e for e in data if e % p != 0]

def main():
    l = []

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

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

if __name__ == "__main__":
    main()

Python: from math import *
search_list = []
search_list_ref = []
prime_list = []
prime_list_ref = []
target1,target2,num = 0,0,2
i,j,k = 0,0,0
flag = 0
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break
if __name__ == "__main__":
    array = list(get_input())
    print("/*------------------------------------*/")
    for i in range(len(array)):
        print(str(array[i]) + "?????????????´???°????±??????????")
    #??\????????¨?????????????????????????????§?´???°????????°?????¢?´¢??????
        #?????????sqrt(int(array[i]))?????§????????§?´???°??????????????????
        ref_target = int(sqrt(int(array[i])))
        search_list_ref.append(2)
        search_list_ref.append(ref_target)
        while target1 < ref_target:
            if search_list_ref == []:
                break
            prime_list_ref.append(search_list_ref[0])
            target1 = search_list_ref[0]
            search_list_ref.remove(target1)
            if target1 > ref_target:
                break
            num = target1
            if target1 == 2:
                for num in range(2,ref_target):
                    if (num % target1 != 0):
                        search_list_ref.append(num)
                if ref_target != 3:
                        search_list_ref.remove(ref_target)
            else:
                for j in search_list_ref:
                    if j % target1 == 0:
                        search_list_ref.remove(j)

        prime_list_ref = prime_list_ref + search_list_ref
        search_list.append(2)
        search_list.append(int(array[i]))

        #?????????????????¬??\?±????????????°?????????????´???°????±??????????
        while target2 < sqrt(int(array[i])):
            prime_list.append(search_list[0])
            target2 = search_list[0]
            search_list.remove(target2)
            if target2 > sqrt(int(array[i])):
                break
            num = target2
            if target2 == 2:
                for num in range(2,int(array[i])):
                    for k in prime_list_ref:
                        if num % k != 0:
                            flag = 1
                        else:
                            flag = 0
                            break
                    if flag == 1:
                        search_list.append(num)
                search_list.remove(int(array[i]))
                prime_list_ref.pop(0)
                search_list[1:1] = prime_list_ref
                break
            elif target2 not in prime_list_ref:
                for j in search_list:
                    if j % target2 == 0:
                        search_list.remove(j)
                break
            else:
                pass
        prime_list = prime_list + search_list
        #print(array[i] + "??\???????´???°????????°???" + str(len(prime_list)))
        print(str(len(prime_list)))
        del search_list_ref[:]
        del prime_list_ref[:]
        del search_list[:]
        del prime_list[:]
        target1 = 0
        target2 = 0
        print("/*------------------------------------*/")

Python: import math

P = []
# 素数一覧リスト
Max = 1000000

def Era(P, Max) :
    D = list(range(2, Max))
    limit = math.sqrt(Max)
    while True :
        p = D[0]

        if limit <= p :
            P += D
            return P

        P.append(p)
        D = [d for d in D if d % p != 0]
        # D に含まれる値かつ p で割り切れない値をリスト化

Era(P, Max)

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

        if n == 1 :
            print(0)
        elif n == 2 :
            print(1)
        elif n >= max(P) :
            print(len(P))
        else :
            for i in range(n + 1) :
                if P[i] == n :
                    print(i + 1)
                    break
                elif P[i] > n :
                    print(i)
                    break

    except :
        break

Python: from math import sqrt
from sys import stdin

def isprime(x) :
    if x == 2 : return x
    elif (x < 2) or (x % 2 == 0) : return False
    else :
        i = 3
        while i <= sqrt(x) :
            if x % i == 0 : return False
            i = i + 2
    return x

for Input in stdin :
    result = []
    for make in range(2, int(Input) + 1) :
        if isprime(make) != False : result.append(make)
    print(len(result))

Python: import math
while True:
    try:
        n=int(input())
        num=list(range(n+1)) #[0,1,,,,n]が出力される
        num[1]=0
        for i in range(n):
            if num[i]>pow(n,0.5):
                break
            if num[i]==0:
                continue
            for j in range(num[i]*2, n+1, num[i]): #num[i]*2からn+1までnum[i]個飛ばしで
                num[j]=0
        print(n+1-num.count(0))
    except:
        break

Python: import sys
for limit in sys.stdin:
    limit = int(limit)
    arr = [2,3,5,7]
    def PrimeNumber(arr,number):
        for i in arr:
            if (number%i==0):
                return False
        return True

    for i in range(2,limit+1):
        if(PrimeNumber(arr,i)):
            arr.append(i)

            
    count = 0
    for i in arr:
        if (i>limit):
            break
        else:
            count += 1
        
    print(count)

Python: from math import sqrt
from sys import stdin

def isprime(x) :
    i = 3
    while i <= sqrt(x) :
        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)