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

Python: import sys
  
lalala = 1000000//30 + 1
f = ([1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0]+[1,0]*7 ) * lalala
f = [0,0,1,1] + f[3:-20]

i = 5
while i < 1000:
    if f[i] == 1:
        j = i * i
        while j <= 1000000:
            f[j] = 0
            j += i + i
    i += 2

for n in sys.stdin:
    i = int(n)
    print(sum(f[:i + 1]))

Python: import sys
import math
M = 1000000
B = int(math.sqrt(M)+1)//6+1
N = M//6
N1 = N+1 if M % 6 == 5 else N
N2 = N+1 if M % 6 >= 1 else N
l = [1] * N1
m = [1] * N2
i = 5
ini = 4
for p in range(B):
    if l[p] == 1:
        l[p+i::i] = [0] * len(l[p+i::i])
        m[ini-1::i] = [0] * len(m[ini-1::i])
    if m[p] == 1:
        m[p+i+2::i+2] = [0] * len(m[p+i+2::i+2])
        l[ini+1::i+2] = [0] * len(l[ini+1::i+2])
    i += 6
    ini += 5
 
for i in sys.stdin:
    n = int(i)
    r =  n-1 if n < 3 else sum(l[0:(n+1)//6])+sum(m[0:(n-1)//6])+2
    print(r)

Python: import sys
results = {}
def fact(n):
    if n in results:
        return results[n]
    ret = [1]
    if n%2==0:
        ret.append(2)
        results[n]=ret
        return ret
    for i in range(3,int(n**0.5)+1,2):
        if n%i==0:
            ret.append(i)
            results[n]=ret
            return ret
    results[n]=ret
    return ret
prime_results = {}
def isPrime(n):
    if n in prime_results:
        return prime_results[n]
    if n<=1:
        return False
    if n==2:
        return True
    if fact(n)==[1]:
        prime_results[n]=True
        return True
    else:
        prime_results[n]=False
        return False
lines = sys.stdin.readlines()
for line in lines:
    inp = int(line)
    s=0
    for i in range(2,inp+1):
        if isPrime(i):
            s+=1
    print (s)

Python: from math import sqrt

I_list=[]

#input syutoku

while True:

	try:

		k=int(input())

		I_list.append(k)

	except:

		break



I_max=max(I_list)

#create list (I_max=100 -> [3,5,7,...,99])

odd_list=[x for x in range(3,I_max+1,2)]

#print(W_list)



P_list=[2]



p=0

#print(I_list)

ct=0

while p<=int(sqrt(I_max)):

	p=odd_list.pop(0)

	P_list.append(p)

	P_baisuu=[p*x for x in range(1, int(I_max/p) +1 )]

	K_list=set(odd_list)-set(P_baisuu)

	odd_list=sorted(list(K_list))

#	print("P_list=")

#	print(P_list)

#	print("odd_list=")

#	print(odd_list)



prime_list=P_list+odd_list

#print("prime_list=")

#print(prime_list)



for i in I_list:

	w=[j for j in prime_list if j<=i ]

	print(len(w))

Python: import sys

def prime(n):
    N = n + 1
    ints = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(N)]
    try:
        ints[0] = ints[1] = False
        ints[2] = ints[3] = ints[5] = True
    except IndexError:
        pass
    sqrt = N ** 0.5

    for i in range(3, N, 2):
        if i >= sqrt:
            break
        for m in range(i ** 2, N, i):
            ints[m] = False
    return ints.count(True)

for line in sys.stdin:
    print(prime(int(line)))

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]+a[1][:(e-1)//6])+2][e>3])

Python: def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    
    for i in range(2, int(n**0.5) + 1):
        if is_prime[i] == False:
            continue
            
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
            
    return [i for i in range(n+1) if is_prime[i]]

while True:
    try:
        n = int(input())
        print(len(primes(n)))
    except:
        break

Python: from math import sqrt
from sys import stdin

def pm(n):
    l = list(range(3,n+1)[0::2])
    p = 3
    i = 0
    p = l[i]
    m = sqrt(n)+1
    while p <= m:
        l = l[:i+1] + [n for n in l[i+1:] if n%p != 0]
        i += 1
        p = l[i]
    return len(l) + 1

for n in stdin:
    print (pm(int(n)))

Python: import sys


def count_prime(n):
    global count, pool
    if not pool:
        return count
    p = pool[0]
    while p <= n:
        pool = tuple(i for i in pool if i % pool[0])
        count += 1
        if not pool:
            break
        p = pool[0]
    return count


inset = list(map(int, sys.stdin))
max_in = max(inset)
pool, count = tuple(range(3, max_in + 1, 2)), 1 if max_in > 1 else 0
inset = [(n, i) for i, n in enumerate(inset)]
inset.sort()
outset = [(t[1], count_prime(t[0])) for t in inset]
outset.sort()

print('\n'.join(map(str, [t[1] for t in outset])))

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(sum(a[:int(e)+1]))

Python: import sys
m=10**6;a=[1]*m;a[0:2]=0,0
for i in range(2,999):
 if a[i]>0:
  for j in range(i*2,m,i):a[j]=0
for e in sys.stdin:print(sum(a[:int(e)+1]))

Python: import sys


def is_prime(n, primes):
    for prime in primes:
        if prime ** 2 > n:
            return True
        if n % prime  == 0:
            return False
    return True


def count_prime():
    primes = [2, 3]
    for i in range(5, 999999, 2):
        if is_prime(i, primes):
            primes.append(i)

    return primes

primes = count_prime()

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

    for i in range(2, n+1):
        if i in primes:
            count += 1

    print(count)

Python: from math import sqrt
from sys import stdin
def pm(n):
    l = list(range(3,n+1)[0::2])
    p = 3
    i = 0
    p = l[i]
    m = sqrt(n)+1
    while p <= m:
        l = l[:i+1] + [n for n in l[i+1:] if n%p != 0]
        i += 1
        p = l[i]
    return len(l) + 1


for i in stdin:
    print(pm(int(i)))

Python: import sys
def fact(n):
    ret = [1]
    for i in range(2,int(n//2)+1):
        if n%i==0:
            ret.append(i)
    return ret
def isPrime(n):
    if n<=1:
        return False
    if n==2:
        return True
    if fact(n)==[1]:
        return True
    else:
        return False
lines = sys.stdin.readlines()
for line in lines:
    inp = int(line)
    s=0
    for i in range(2,inp+1):
        if isPrime(i):
            s+=1
    print (s)

Python: import sys
a=[0,0]+[1]*10**6
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: import sys
def isprime(num):
   i = 2
   count = 0
   while i< num:
       if num % i == 0:
           count += 1
       i += 1
   if count == 0:
       return 1
   else:
       return 0
for line in sys.stdin:
   num = int(line)
   count_prime = 0
   for i in range(2,num+1):
       if(isprime(i) == 1):
           count_prime += 1
   print(count_prime)
else:
   exit()

Python: import math

def Eratos(n):
	primes = [2]
	num = [2*i+1 for i in range(1,n//2)]
	tmp = []

	top = 1
	while top < math.sqrt(n):
		top = num[0]
		for i in range(1,len(num)):
			if num[i] % top != 0:
				tmp.append(num[i])
		num = tmp
		tmp = []
		primes.append(top)
	for i in range(len(num)):
		primes.append(num[i])
	return primes

def list_count(list_a,n):
	cont = 0
	for i in range(len(list_a)):
		if list_a[i] > n:
			break
		else:
			cont += 1
	return cont

primes = Eratos(1000000)
while True:
	try:
		n = int(input())
		print(list_count(primes,n))
	except EOFError:
		break