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
m=166666;s=[1]*m;t=[1]*m
for i in range(m):
 if s[i]:
  k=6*i+5
  s[i+k::k]=[0]*len(s[i+k::k])
  t[-2-i+k::k]=[0]*len(t[-2-i+k::k])
 if t[i]:
  k=6*i+7
  s[-2-i+k::k]=[0]*len(s[-2-i+k::k])
  t[i+k::k]=[0]*len(t[i+k::k])
for e in map(int,sys.stdin):
 print((e-1,sum(s[:(e+1)//6])+sum(t[:(e-1)//6])+2)[e>3])

Python: # -*- coding: utf-8 -*-
import sys
array=[]
for i in sys.stdin:
    array.append(int(i))
m=max(array)
prime=[1]*(m+1)
prime[0]=prime[1]=0
for i in range(2,int(m**0.5)+1):
    if prime[i] ==1:
        for j in range(i*i,m+1,i):
            prime[j]=0
for i in range(len(array)):
    print(sum(prime[:array[i]+1]))

Python: M = 10**6

p = [0]*(M+60)
sM = M**0.5
for x in range(1, int(sM/2)+1):
    v = 4*x*x + 1; y = 8
    while v <= M:
        if v % 12 != 9: # v % 12 in [1, 5]
            p[v] ^= 1
        v += y; y += 8
for x in range(1, int(sM/3**0.5)+1, 2):
    v = 3*x*x + 4; y = 12
    while v <= M:
        if v % 12 == 7:
            p[v] ^= 1
        v += y; y += 8
for x in range(2, int(sM/2**0.5)+1):
    v = 2*x*(x+1)-1; y = 4*x-8
    while 0 <= y and v <= M:
        if v % 12 == 11:
            p[v] ^= 1
        v += y; y -= 8

for n in range(5, int(sM)+1):
    if p[n]:
        for z in range(n*n, M, n*n):
            p[z] = 0
p[2] = p[3] = 1

c = [0]*M
cnt = 0
for i in range(M):
    if p[i]:
        cnt += 1
    c[i] = cnt

while 1:
    try:
        n = int(input())
    except:
        break
    print(c[n])

Python: import math as m
n=int(input())
a=[0]*(n+1)
a[0],a[1]=1,1
for i in range(2,int(m.sqrt(n))+1):
	for j in range(2,int(n/i)+1):
		a[i*j]=1
print(a.count(0))

Python: import sys

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 = []
    
    for line in sys.stdin:
        l.append(int(line))

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

if __name__ == "__main__":
    main()

Python: # coding: utf-8

import sys
import math


if __name__ == '__main__':
	input_list = sys.stdin.readlines()

	for num in input_list:
		target_number = int(num.replace('\n', ''))
		serial_number_list = [r for r in range(2, target_number + 1)]
		multiple_list = []

		while math.sqrt(target_number) >= serial_number_list[0]:
			serial_number = serial_number_list[0]
			i = 1
			multiple_list.append(serial_number)

			while target_number >= serial_number * i:
				
				if serial_number * i in serial_number_list:
					serial_number_list.pop(serial_number_list.index(serial_number * i))

				i += 1

		print(len(multiple_list + serial_number_list))

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: l = [1 for i in range(10 ** 6 + 1)]
l[0] = l[1] = 0
for i in range(10 ** 6 + 1):
  if l[i] == 1:
    for j in range(i * 2, 10 ** 6 + 1, i):
      l[j] = 0
while 0 == 0:
  try:
    n = int(input())
    c = 0
    for i in range(n + 1):
      c += l[i]
    print(c)
  except EOFError:
    break

Python: import math
import sys

a = [1]*10000000
a[0] = a[1] = 0

for i in range(2,int(math.sqrt(2000000))):
    if a[i] == 1:
        for j in range(i+i,2000000,i):
            a[j] = 0

for i in range(1,2000000):
    a[i] += a[i-1]
    
for line in sys.stdin:
    print(a[int(line)])

Python: import sys
import math as mas

def sieve(n):
	p=[True for i in range(n+1)]
	p[0]=p[1]=False
	end=int(n**0.5)
	for i in range(2,end+1):
		if p[i]:
			for j in range(i*i,n+1,i):
				p[j]=False
	return p
	
sosu=sieve(1000010)
for i in sys.stdin:
	print(sum(sosu[t] for t in range(int(i))))

#	a,b=map(int,i.split())
#	print(gcd(a,b),lcm(a,b))

Python: # the sieve of Eratosthenes
primes = [1] * 1000000
primes[0] = 0
primes[1] = 0
for i in range(2, 1000):
    if primes[i]:
        primes[i*2::i] = [0] * len(primes[i*2::i])

from itertools import accumulate
acc_primes = list(accumulate(primes))

for i in range(30):
    try:
        n = int(input())
        print(acc_primes[n])
    except EOFError:
        break

Python: import sys

MAX = 999999

def is_prime(n):
  if n == 2:return True
  if n % 2 == 0:return False
  for i in range(3,int(n**0.5)+1,2):
    if n % i == 0:return False
  return True

def prime_list(n):
  result = []
  if n >= 2:result.append(2)
  for i in range(3,n+1,2):
    if is_prime(i):result.append(i)
  return result

L = prime_list(int(MAX**0.5))

def is_prime_2(n):
  a = int(n ** 0.5)
  for i in L:
    if i > a:return True
    if n % i == 0:return False
  return True

def prime_count(n):
  result = 0
  if n >= 2:result+=1
  for i in range(3,n+1,2):
    if is_prime_2(i):result+=1
  return result

L2 = prime_list(MAX)

def prime_count_2(n):
  for i,v in enumerate(L2):
    if v > n:return i
  return len(L2)

for n in sys.stdin:
  print(prime_count_2(int(n)))

Python: import math
n = 1000001
rn = round(math.sqrt(n)) + 1
tbl = [True for i in range(n)]
tbl[0], tbl[1] = False,False
for i in range(4,n,2):
    tbl[i] = False
for i in range(3,rn,2):
    if tbl[i]:
        for j in range(i*2,n,i):
            tbl[j] = False
n = int(input())
while 1:
    print(sum(tbl[:n+1]))
    try: n = int(input())
    except EOFError:break