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: # -*- coding: utf-8 -*-

list = [1]*1000000
list[0] = 0
list[1] = 0
for i in range(1, 1000000):
    if list[i] == 1:
        for j in range(i**2, 1000000, i):
            list[j] = 0

for i in range(2, 1000000):
    list[i] += list[i -1]
while True:
    try:
        n = int(raw_input())
        print(list[n])
    except EOFError:
        break

Python: import math
import sys

def prime_calc(n):
    rootN = math.floor(math.sqrt(n))
    prime = [2]
    data = [i + 1 for i in range(2,n,2)]
    while True:
        p = data[0]
        if rootN <= p:
            return len(prime + data)
        prime.append(p)
        data = [e for e in data if e % p != 0]

def main():
    l = []

    for line in sys.stdin:
        l.append(int(line))        

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

if __name__ == "__main__":
    main()

Python: MAX = 1000000
s = [1]*MAX
s[0] = 0
s[1] = 0

start = 2
while True:
    pmb = 0
    for i in range(start, MAX):
        if s[i] == 1:
            pmb = i
            break
    if pmb == 0:
        break
    
    for i in range(pmb**2, MAX, pmb):
        s[i] = 0
    start += 1

while True:
    try:
        n = int(input())
        c = 0
        for i in range(2, n+1):
            if s[i] == 1:
                c += 1
        print(c)
    except EOFError:
        break

Python: import math

while True:
    try:
        n = int(input())
        c = [1 for i in range(n)]
        c[0] = 0
        i = 2
        while i**2 <= n:
            j = i*2
            while j <= n:
                c[j - 1] = 0
                j += i
            i += 1
        print(sum(c))
    except:
        break

Python: lis=[1 for i in range(int(1e6+1))]

lis[0]=lis[1]=0

for i in range(int(1e6)+1):
    if lis[i]:
        for j in range(i*2,int(1e6+1),i):
            lis[j]=0

while True:
    try:
        n=int(input())
        cnt=0
        for i in range(n+1):
            if lis[i]:
                cnt+=1

        print(cnt)
        
        
    except:
        break

Python: N = 1000000
p = [ 1 ] * N

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

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

Python: from sys import stdin
a = [True]*1000000
for i in range(2,1000000):
    if a[i]:
        for j in range(i+i, 1000000)[::i]:
            a[j] = False

b = [None]*1000000
b[0] = b[1] = 0
for i in range(2,1000000):
    if a[i]:
        b[i] = b[i-1] + 1
    else:
        b[i] = b[i-1]

while True:
    try:
        print(b[int(input())])
    except:
        break

Python: import sys,random

rand = random.randint

def prime(n):
	if n == 2:
		return True
	if n == 1 or n & 1 == 0:
		return False
	d = n-1
	while d & 1 == 0:
		d >>= 1
	for i in range(20):
		a = rand(1,n-1)
		t = d
		y = pow(a, t, n)
		while t != n-1 and y != 1 and y != n-1:
			y = pow(y,2,n)
			t <<= 1
		if y != n-1 and t & 1 == 0:
			return False
	return True

a = [prime(i) for i in range(1000000)]

for s in sys.stdin:
	i = int(s)
	print(a[:i+1].count(True))

Python: import sys
a=[True]*500000
for i in range(3,999,2):
 if a[i//2]:a[(i*i)//2::i]=[False]*len(a[(i*i)//2::i])
for e in map(int,sys.stdin):print([e-1,sum(a[:(e+1)//2])][e>3])

Python: import math

m=999999
l=[False]*m
l[1]=True
l[2]=True
for i in range(5,m+1):
    if i%2==0 or i%3==0:continue
    for e in range(2,int(math.sqrt(i)+1)):
        if i%e==0:
            break
    else:
        l[i-1]=True
    
while True:
    try:n=int(input())
    except:break
    print(len([i for i in l[:n:] if i]))

Python: import math

def lenPrimeNumber(num):
	if num == 1:
		return 1
	else:
		sList = list(range(2, num + 1))
		pList = []
		while sList[0] < math.sqrt(num):
			pList.append(sList.pop(0))
			sList = list(filter(lambda x: x % pList[-1] != 0, sList))
		pList.extend(sList)

		return len(list(map(lambda x: num % x == 0, pList)))

def inputGenerator():
	while True:
		try:
			yield input()
		except EOFError:
			break

if __name__ == "__main__":
	for x in list(inputGenerator()):
		print(lenPrimeNumber(int(x)))

Python: DP = [0,1,2]

while True:
    try:
        k = int(input())
        n = 1000000
        if len(DP) < n:
            for i in range(len(DP) + 1,n+1):
                YN = 0
                for j in range(2,i - 1):
                    if i % j == 0:
                        DP.append(DP[len(DP) - 1])
                        YN = 1
                        break
                    elif j ** 2 > i:
                        DP.append(DP[len(DP) - 1] + 1)
                        break

        print(DP[k - 1])
    except EOFError:
        break

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 = int(input())
    except:
        break
    else:
        n = 1
        if x == 0 or 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: #!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

N = 1000000

TABLE = [True] * N

def sieve():
    TABLE[1] = False

    for i in range(4, N, 2):
        TABLE[i] = False

    for i in range(6, N, 3):
        TABLE[i] = False

    for i in range(6, N, 6):
        p1 = 6*i - 1
        p2 = 6*i + 1

        if p1 >= N: break

        if TABLE[p1]:
            for j in range(2*p1, N, p1):
                TABLE[j] = False

        if p2 >= N: break

        if TABLE[p2]:
            for j in range(2*p2, N, p2):
                TABLE[j] = False

def main():
    sieve()

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

        cnt = sum(map(lambda k: TABLE[k], range(1, n+1)))
        print(cnt)

if __name__ == "__main__": main()

Python: a = [True for i in range(1000000)]
i = 3
while i * i < 1000000:
    for j in range(3 * i, 1000000, 2 * i): a[j] = False
    i += 2

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

    count = int(n >= 2) + sum(a[i] for i in range(3, n + 1, 2))
    print(count)

Python: while True:
	try:
		n=int(input())
		a=[True]*(n+1)
		a[0]=a[1]=False
		for i in range(2,int(n**0.5)+1):
			if a[i]:
				for j in range(i**2,n+1,i):
					a[j]=False
		print(a.count(True))
	except:
		break

Python: LIMIT = 10000000
 
isPrime = [True for _ in range(LIMIT)]

isPrime[0] = isPrime[1] = False
 
for i in range(2, int(LIMIT ** 0.5)+1):
  if isPrime[i]:
    for j in range(i * i, LIMIT, i):
      isPrime[j] = False
 
try:
    while True:
        n = int(input())
        count = 0
        for i in range(n+1):
            if isPrime[i]:
                count += 1
        print(count)
except EOFError:
  pass