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: def prime_count(N):
    primes = [2, 3]
    count = 1
    for n in range(5, N+1, 2):
        isprime = True
        for i in range(1, len(primes)):
            if primes[i] ** 2 > n:
                break
            if n % primes[i] == 0:
                isprime = False
                break
        if isprime:
            count += 1
    return count

while True:
    try:
        print(prime_count(int(input())))
    except:
        break

Python: import sys
from math import sqrt

for line in sys.stdin:
    n = int(line.strip())
    L, pn, tmp = int(sqrt(n)), [], [i for i in range(2, n+1)]
    while tmp[0] < L+1:
        v = tmp.pop(0)
        pn.append(v)
        tmp = list(filter(lambda x: x%v!=0, tmp))
    for t in tmp: pn.append(t)
    print(len(pn))

Python: def main():
	import sys

	MAX = 1000000

	table = [True]*1000000
	table[0] = table[1] = False

	primes = []
	counted = 0

	for i in range(MAX):
		if table[i]:
			primes.append(i)
			for j in range(2*i, MAX, i):
				table[j] = False

	for line in sys.stdin:
		n = int(line)

		cnt = 0
		for prime in primes:
			if prime > n:
				break
			else:
				cnt += 1
		print(cnt)


if __name__ == '__main__':
	main()

Python: def sieve(n=10**6):
  p=[1]*(n+1)
  for i in range(2,n+1):
    if p[i]:
      for j in range(2*i,n+1,i):p[j]=0
  p[0],p[1]=0,0
  return p
while True:
  try:print(sum(sieve(int(input()))))
  except:break

Python: import math
import sys

def E(d):

    p_list = [] 
    p=0
    tmp = []
    l = len(d)
    num = int(math.sqrt(len(d)))+1
    for i in d:
        i=d[0]
        if i>num:
            break
        else:
            # p_list.append(i)
            p=p+1
            for j in d:
                if j%i == 0:
                    d.remove(j)
                    l = l-1
        
    # print(len(p_list)+len(d))
    print(p+l)

for line in sys.stdin:
    x= [i for i in range(2,(int(line)+1))]
    E(x)

Python: import sys


xx = 500000
f = [0, 1] * xx

i = 3
while i * i <= 2 * xx:
    if f[i] == 1:
        j = i * i
        while j <= 2 * xx:
            f[j] = 0
            j += i + i
    i += 2

f.pop(0)
f.pop(1)

for n in sys.stdin:
    i = int(n)
    if i < 2:
        print(0)
    else:
        print(sum(f[:i - 1]))

Python: # PrimeNumber

from itertools import product
import math


def nOfPrime(m):
    return m * 2


if __name__ == "__main__":
    while True:
        try:
            n = int(input())
            prm = 1
            nlist = []
            nlist2 = []
            plist = []

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

            while True:
                #print(nlist, " ", math.sqrt(n))
                if nlist[0] > math.sqrt(n):  # 終了条件
                    #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))

        except EOFError:
            break  # escape from while loop

pass
#

Python: try:
    while True:
        n = int(input())
        datasets = list(range(2, n+1))
        answers = set([])
        while datasets:
            i = datasets[0]
            datasets = filter(lambda data: data%i != 0, datasets)
            answers.add(i)
        print(len(answers))
except:
    pass

Python: import math, sys


def erastos(n):
    n += 1
    try:
        v = [0 if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else 1 for i in range(n)]
        v[0] = v[1] = 0
        v[2] = v[3] = v[5] = 1
    except IndexError:
        return [0, 0, 1, 1, 0, 1][:n]
    sqrt = math.sqrt(n)
    for serial in range(3, n, 2):
        if serial > sqrt:
            return v
        for s in range(serial ** 2, n, serial):
            v[s] = 0
if __name__ == '__main__':
    while True:
        try:
            n = int(input())
        except:
            break
        v = erastos(n)
        primes = [i for i, b in enumerate(v) if b == True]
        print(len(primes))

Python: primes = [0, 0] + [1] * 999999
for i in range(2, 1000):
    if primes[i]:
        for j in range(i*i, 1000000, i):
            primes[j] = 0

answer = [0] * 1000000
for i in range(2, 1000000):
    answer[i] += primes[i] + answer[i-1]

while True:
    try:
        n = int(input())
    except:
        break
    print(answer[n])

Python: LIMIT = 999999

prime = [0, 1] + [0 if i % 2 == 0 else 1 for i in range(3, LIMIT + 1)]

for i in range(3, LIMIT + 1):
    if prime[i - 1]:
        for j in range(i ** 2, len(prime), i):
            prime[j - 1] = 0

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

Python: from sys import stdin

for Input in stdin :
    Input = int(Input)
    if (Input <= 10) : 
        if   (Input <= 1) : print(0)
        elif (Input == 2) : print(1)
        elif (Input == 3) or (Input == 4) : print(2)
        elif (Input == 5) or (Input == 6) : print(3)
        else : print(4)
    else :
        result = 4
        for make in range(11, Input + 1, 2) :
            if (make % 2 != 0) or (make % 3 != 0) or (make % 5 != 0) or (make % 7 != 0) : result += 1
        print(result)