Go: package main

// https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}
		maybePrime := make([]bool, n+1)
		for i := 0; i <= n; i++ {
			maybePrime[i] = true
		}

		maybePrime[0] = false
		maybePrime[1] = false
		for i := 2; i <= int(math.Sqrt(float64(n)))+1; i++ {
			j := i * 2
			for j <= n {
				maybePrime[j] = false
				j += i
			}
		}

		nPrimes := 0
		for _, p := range maybePrime {
			if p {
				nPrimes++
			}
		}
		// fmt.Println(maybePrime)
		fmt.Println(nPrimes)
	}
}

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)

Python: def sieve_of_erastosthenes(num):
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True

    for serial in range(3, int(num ** 0.5) + 1, 2):
        
        if input_list[serial] is True:
            
            for s in range(serial ** 2, num, serial): 
                input_list[s] = False

    # print([i for i, b in enumerate(input_list) if b == True])
    return sum(input_list)


if __name__ == '__main__':
    while True:
        try:
            n = int(input())
        except:
            break

        if 5 >= n:
            print(1)
        
        else:
            print(sieve_of_erastosthenes(n))

Python: l = [True] * 100000
for i in range(2, 100000):
    if (l[i - 1]):
        for j in range(i ** 2 - 1, 100000, i):
            l[j] = False

while True:
    try:
        n = int(input())
        print(l[1:n].count(True))
    except:
        break

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):
            return pl

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