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: LIMIT = 999999

prime = [0, 1] + [0 if i % 2 == 0 else 1 for i in range(3, LIMIT + 1)]

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

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

Python: from sys import stdin

for Input in stdin :
    Input = int(Input)
    if (Input <= 10) : 
        if   (Input <= 1) : print(0)
        elif (Input == 2) : print(1)
        elif (Input == 3) or (Input == 4) : print(2)
        elif (Input == 5) or (Input == 6) : print(3)
        else : print(4)
    else :
        result = 4
        for make in range(11, Input + 1, 2) :
            if (make % 2 != 0) or (make % 3 != 0) or (make % 5 != 0) or (make % 7 != 0) : result += 1
        print(result)

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

import sys
import math

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

def is_prime(no):
    if no == 2:
        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 = {}                         # ????????°?????§????´???°????????°
    while True:
        num = sys.stdin.readline()
        if num is None or num.strip() == '':
            break

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

        print(cnt)

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

Python: import sys

values = []
for line in sys.stdin:
    if 1000000 > int(line):
        values.append(int(line))

for val in values:
    prime = 0
    i = 2
    while i <= val:
        j = 2
        while j <= i:
            if i % j == 0:
                if j == i:
                    prime += 1
                else:
                    break
            j += 1
        i += 1
    print(prime)

Python: import sys
e=list(map(int,sys.stdin))
m=max(e)+1;a=[1]*m;a[0:2]=0,0
for i in range(2,int(m**.5)+1):
 if a[i]>0:
  for j in range(i*2,m,i):a[j]=0
for i in range(m):a[i]+=a[i-1]
for x in e:print(a[x])

Python: def check_prime(goal):
    true_or_false=False
    for i in range(2,goal):
        if goal%i==0:
             true_or_false=True
             break
    if true_or_false==False:
        return True
    else:
        return False
anss=[]
while True:
    try:
        num=int(input())
        num_of_prime=0
        for i in range(2,num+1):
           if check_prime(i):
               num_of_prime+=1
        anss.append(num_of_prime)
    except:
        break
for ans in anss:
    print(ans)

Python: import sys

for user in sys.stdin:
    n = int(user)
    num = 1
    for i in range(2, n+1):  # ?´???°??¨??????????????°
        for j in range(2, i):  # ????????°
            if i % j == 0:
                break
            if j == i-1:
                num += 1

    print(num)

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

Python: #!/usr/bin/env python3

"""Enumerates primes in an interval.

Verification: [0009](https://onlinejudge.u-aizu.ac.jp/status/users/hamukichi/submissions/1/0009/judge/4571021/Python3)
"""


import math
import sys


def segment_sieve(begin, end):
    """Enumerates the prime numbers in [`begin`, `end`).

    Returns (as a tuple):

    - `is_prime`: a list of bool values.
      If an integer `i` is a prime number, then `is_prime[i - begin]` is True.
      Otherwise `is_prime[i -begin]` is False.
    - `primes`: a list of prime numbers in [`begin`, `end`).
    """

    assert 1 < begin <= end
    sqrt_end = math.ceil(math.sqrt(end))
    is_prime_small = [True for i in range(sqrt_end)]
    is_prime_small[0] = False
    is_prime_small[1] = False
    is_prime = [True for i in range(end - begin)]
    for i in range(2, sqrt_end):
        if is_prime_small[i]:
            for j in range(2 * i, sqrt_end, i):
                is_prime_small[j] = False
            for k in range(max(2, (begin + i - 1) // i) * i, end, i):
                is_prime[k - begin] = False
    primes = [i for i, cond in enumerate(is_prime, begin) if cond]
    return is_prime, primes


def main():
    ns = [int(n) for n in sys.stdin.readlines()]
    max_n = max(ns)
    begin = 2
    is_prime, _ = segment_sieve(begin, max_n + 1)
    for n in ns:
        print(sum(is_prime[:n + 1 - begin]))


if __name__ == '__main__':
    main()

Python: import sys
for i in sys.stdin:
    n = int(i)
    if n <= 3:
        print(max(0, n - 1))
        continue
    a = [2, 3]
    for k in range(5, n + 1, 2):
        for e in a:
            if k % e == 0:
                break
        else:
            a.append(k)
    print(len(a))

Python: #79 素数の数

import math

while(1):
    try:
        n = int(input())
    except:
        break
    
    m = int(math.sqrt(n))
    keys = [n // i for i in range(1, m+1)] #1からm+1の間のみn//iを行う
    keys += range(keys[-1]-1, 0, -1) #range(始まりの数値,最後の数値,増加量)
    h = {i: i-1 for i in keys}
    
    for i in range(2, m+1):
        if h [i] > h[i-1]:
            hp = h[i-1]
            i2 = i*i
            for j in keys:
                if j < i2:
                    break
                h[j] -= h[j // i] - hp
    print(h[n])

Python: import sys
x = 1000000
xx = 500000
f = [1, 0] * xx
f[0] = 0
f[1] = 1  # [02305070...]12345
i = 3
while i < x:
    if f[i] == 1:
        j = i
        y = x // i + 1
        while j < y:
            f[j] = 0
            j += i + i
    i += 2

for n in sys.stdin:
    i = int(n)
    if i < 2:
        print(0)
    else:
        print(sum(f[:i - 1]))