Go: package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = i
        }

        Soe()

        for i := 0; i < MAX; i++ {
                primes[i] %= 2
        }
        primes[1] = 0
        primes[2] = 1
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := 2; j < MAX/i; j++ {
                                if i * j < MAX {
                                        primes[i*j] = 0
                                }
                        }
                }
        }
}

Python: while 1:
    try:
        count=0;
        x=int(input())
        if x==1:
            print(0)
        elif x==2:
            print(1)
        else:
            a=[int(i) for i in range(2,x+1)]
            for i in  range(len(a)):
                count1=0
                for j in range(2,a[i]):
                    if a[i]%j==0:
                        count1+=1
                if count1==0:
                    count+=1
            print(count)        
    except EOFError:
        break

Python: import sys

def create_prime_list(limit):
    """ ??¨??????????????????????????§limit?????§????´???°?????????????±???????
    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
    """
    x = limit**0.5
    primes = []
    nums = tuple(x for x in range(2, limit+1))
    while nums[0] <= x:
        primes.append(nums[0])
        current_prime = nums[0]
        nums = tuple(x for x in nums if x % current_prime != 0)
    primes.extend(nums)
    return primes


if __name__ == '__main__':
    # ?´???°?????§?????¨???
    primes = create_prime_list(999999)

    # ??????????????\???
    for line in sys.stdin:
        target = int(line)

        ans = tuple(x for x in primes if x <= target)
        print(len(ans))

Python: def Eratosthenes(n):
	N = [1 for i in range(0,n+1)]
	i = 3
	while i*i<=n:
		if N[i]:
			j = i*i
			while j<=n:
				N[j] = 0
				j += i*2
		i += 2
	return N

while True:
	N = Eratosthenes(999999)
	try:
		n = int(input())
	except EOFError:
		break
	cnt = 0
	if n>=2:
		cnt = 1
	for i in range(3, n+1, 2):
		cnt += N[i]
	print(cnt)

Python: import sys
import math

def Prime():
    isPrime=[1 for i in range(0,1000000)]
    isPrime[0]=isPrime[1]=0
    numPrime=[0 for i in range(0,1000000)]

    for i in range(2,int(math.sqrt(1000000)),1):
        if isPrime[i]==1:
            numPrime[i]=numPrime[i-1]+1
            for j in range(i+i,1000000,i):
                isPrime[j]=0
        else:
            numPrime[i]=numPrime[i-1]


    for n in sys.stdin:
        print(numPrime[int(n)])
    

#testWriteFile()
Prime()

Python: from sys import stdin

def isprime(n):
    from math import floor,sqrt
    if n <= 1:
        return False
    for i in range(2,floor(sqrt(n))+1):
        if n % i == 0:
            return False
    return True

N = []
for line in stdin:
    N.append(int(line))
for i in N:
    ans = 0
    for j in i:
        if isprime(j):
            ans += 1
    print(ans)

Python: import argparse

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():
    l = []

    parser = argparse.ArgumentParser()
    parser.add_argument("filename", help="The filename to be processed")
    args = parser.parse_args()

    if args.filename:
        with open(args.filename) as f:
            for line in f:
                a = int(line.rstrip())
                l.append(a)

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

if __name__ == "__main__":
    main()

Python: import sys
import math

N = 1000000
primes = [1] * N
primes[0] = 0
primes[1] = 0
primes[4::2] = [0] * len(primes[4::2])

for i in range(3,int(math.sqrt(N)),2):
    if primes[i]:
        primes[i*i::i*2] = [0] * len(primes[i*i::i*2])

for i in sys.stdin:
        n = int(i)
        print(sum(primes[0:n]))

Python: def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
t = 0
while t == 0:
    try:
        x = 5
    except:
        break
    else:
        n = 1
        if x == 0 or x == 1:
            print(0)
        elif x == 2:
            print(1)
        else:
            for i in range(0,x + 1,2):
                if is_prime(i):
                    n += 1
    print(n)

Python: # -*- coding: utf-8 -*-

import sys
import os
import math



def eratosthenes(n):
    lst = [i for i in range(2, n+1)]
    primes = []
    sqrt_n = math.sqrt(n)

    while lst:
        first = lst.pop(0)
        if first < sqrt_n:
            primes.append(first)
            new_lst = []
            for v in lst:
                if v % first != 0:
                    new_lst.append(v)
            lst = new_lst
        else:
            # ??????
            return primes + [first] + lst

for s in sys.stdin:
    n = int(s)
    lst = eratosthenes(n)
    print(len(lst))

Python: import math

def main():
    while True:
        try:
            n = int(input())
            count = 0
            for x in range(2,n+1):
                flag = 0
                for i in range(2,int(n**0.5)):
                    if x%i == 0:
                        flag = 1
                        break
                if flag == 0:
                    count += 1
                    if n == 2:
                        n += 1
            print(count)      
        except EOFError:
            exit()
      

if __name__ == '__main__':
    main()

Python: import numpy
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break
def primesfrom3to(n):
    sieve = numpy.ones(int(n/2), dtype=numpy.bool)
    if n%2 != 0:
        sieve = numpy.append(sieve,n/2)
    for i in range(3,int(n**0.5)+1,2):
        if sieve[int(i/2)]:
            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: num = []
while True:
    try:
        num.append(int(input()))
    except EOFError:
        break

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
lst.append(lst[-1]+1)

for i in num:
    for j in lst:
        if i < j:
            print(lst.index(j))
            break

Python: import sys,math
def prime(n):
    a = [0] * (n+1)
    for i in range(2, n+1):
        isPrime = a[i] == 0
        a[i] = a[i-1] + isPrime * 1
        if isPrime:
            r = slice(i*2, n+1, i)
            a[r] =[1 for x in a[r]]
    return a
prime = prime(999999)
for i in sys.stdin:
    print(prime[int(i)])