Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var resultArr [100]int
	var inputCount, primeCount, input int
	for {
		fmt.Scanf("%d", &input)
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		resultArr[inputCount] = primeCount
		if inputCount == 30 {
			break
		}
		primeCount = 0
		inputCount++
	}
	for _, v := range resultArr {
		fmt.Printf("%d\n", v)
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2:
		return true
	case num < 2 || num%2 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

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

Python: # ?´???°?????°?????¨?????????????????°??????

import sys
import math

prim_no = {2: True}                    # ????????°????´???°??§??????????????????????????????

def is_prime(no):
    if no == 2 or no == 1:
        return True
    
    if no % 2 == 0:
        return False

    if prim_no.get(no) is not None:
        return prim_no.get(no)

    max_check = int(math.sqrt(no))
    for i in range(3, max_check+1, 2):
        if no % i == 0:
            prim_no[no] = False
            return False

    prim_no[no] = True
    return True

def main():
    prim_vals = {}                         # ????????°?????§????´???°????????°
    num_data = []                          # ?????????????????????
    
    while True:
        num = sys.stdin.readline()
        if num is None or num.strip() == '':
            break

        num = int(num.strip())
        num_data.append(num)

    sorted_num_data = sorted(num_data)
    prim_num = {}
    
    for num in sorted_num_data:
        if prim_vals.get(num) is not None:
            cnt = prim_vals.get(num)
        else:
            if num == 1:
                cnt = 0
            else:
                cnt = 0

                if num % 2 == 0:
                    start_num = num -1
                else:
                    start_num = num
                    
                for i in range(start_num, 0, -2):
                    if prim_vals.get(i) is not None:
                        cnt += prim_vals.get(i)
                        break
                    
                    if is_prime(i):
                        cnt += 1
                        
                prim_vals[num] = cnt # ????????°?????§????´???°????????°????????????
        prim_num[num] = cnt

    for num in num_data:
        print(prim_num[num])

if __name__ == '__main__':
    main()
    #print(prim_no)

Python: from sys import stdin


def prime(n):
    Prime = [i for i in range(n + 1)]
    for i in range(2, n + 1):
        for j in range(2, int(n / i) + 1):
            Prime[i * j] = 0
    Prime[0], Prime[1] = 0, 0
    ans = [i for i in Prime if not (i == 0)]
    return len(ans)


for line in stdin:
    n = int(line)
    print(prime(n))

Python: import sys
m=166666;a=[[1]*m for _ in[0]*2]
for i in range(m):
 if a[0][i]:
  k=6*i+5
  a[0][i+k::k]=[0]*len(a[0][i+k::k])
  a[1][-2-i+k::k]=[0]*len(a[1][-2-i+k::k])
 if a[1][i]:
  k=6*i+7
  a[0][-2-i+k::k]=[0]*len(a[0][-2-i+k::k])
  a[1][i+k::k]=[0]*len(a[1][i+k::k])
for e in map(int,sys.stdin):
 print([e-1,sum(a[0][:(e+1)//6])+sum(a[1][:(e-1)//6])+2][e>3])