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

Python: def check_prime(goal):
    true_or_false=False
    for i in range(2,goal):
        if goal%i==0:
             true_or_false=True
    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 numpy as np

def PI(n):
    N_MAX = int(np.sqrt(n+1))
    is_prime = np.ones((n+1,),dtype=bool)
    is_prime[:2] = 0
    for i in range(2,N_MAX+1):
        is_prime[2*i::i] = 0
    return sum(is_prime)

def main():
    print(PI(int(input())))

if __name__ == "__main__":
    main()

Python: def e(n):
    array = [1]*(n+1)
        
    k = 2
    
    while k*k <= n:
        if array[k] == 1:
            i = k
    
            while (i <= 10/k):
                array[k*i] = 0
                i += 1
        
        k += 1
    
    # ?´???°(array[i]==1)?????????
    prime = []
    i = 2
    
    while i <= n:
        if array[i] == 1:
            prime.append(i)
        i += 1
    
    return len(prime)


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

Python: # -*- coding;utf-8 -*-

def sieve(n):
    p = 0
    primes = []
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if(is_prime[i]):
            primes.append(i)
            p += 1
            for j in range(i*2,n+1,i):#iごとに増える
                is_prime[j] = False
    return p

if(__name__ == "__main__"):
    while(True):
        try:
            n = int(input())
        except:
            break
        print(sieve(n))

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():
    a = []

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

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

if __name__ == "__main__":
    main()

Python: import sys

l = [True] * 100000
for i in range(2, 100000):
    if (l[i - 1]):
        for j in range(i ** 2 - 1, 100000, i):
            l[j] = False
n = [int(line) for line in sys.stdin]
for nn in n:
    print(l[1:int(n)].count(True))

Python: import math


def sieve_of_erastosthenes(num):
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):
        
        if serial >= sqrt:
            return input_list

        for s in range(serial ** 2, num, serial): 
            input_list[s] = False


if __name__ == '__main__':
    while True:
        try:
            n = int(input())
        except:
            break

        if 2 >= n:
            print(1)

        else:
            input_list = sieve_of_erastosthenes(n)

            print(sum(input_list))

Python: import math
lst = [1 for i in range(1000001)]
prime = [0, 0]
lst[0] = lst[1] = 0
cnt = 0
for i in range(2,1000001):
    if lst[i] == 1:
        cnt += 1
        for j in range(i*2,1000001,i):
            lst[j] = 0
    prime.append(cnt)
                
while(True):
    try:
        print(prime[int(input())])
    except:
        break

Python: p = [1] * (1000000 + 1)
p[0], p[1] = 0, 0
for i in range(2, int(1000000 ** 0.5) + 1):
    if not p[i]:
        continue
    for j in range(2 * i, 1000000 + 1, i):
        p[j] = 0

while 1:
    try:
        n = int(input())
        print(sum(p[:n+1]))
    except:
        break

Python: #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys

LIMIT = 1000000
is_prime = [True] * (LIMIT+1)
p = 2
while p**2 <= LIMIT:
    if is_prime[p]:
        for i in range(p*2, LIMIT+1, p):
            is_prime[i] = False
    p += 1

for line in sys.stdin.readlines():
    n = int(line.strip())
    if n <= 1:
        print(0)
        continue
    if n == 2:
        print(1)
        continue
    num_prime = 1
    for i in range(3, n+1):
        if is_prime[i]:
            num_prime += 1
    print(num_prime)

Python: def isprime(x):
    if x == 2:
        return True
    elif x < 2 or x%2 == 0:
        return False
    i = 3
    while i <= pow(x,1/2):
        if x%i == 0:
            return False
        i = i + 2
    return True
import sys
import itertools as it
line = sys.stdin.readlines()
for n in line:
    n = int(n)
    count = 0
    for s in range(2,n+1):
        if isprime(s):
            count += 1
    print(count)

Python: import sys
a=[0]*10**6
for i in range(1,10**6):a[i]=a[i-1]+int(2 in[i,pow(2,i,i)])
for e in sys.stdin:print(a[int(e)])

Python: # coding: utf-8

LIMIT = 999999

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

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

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

    print(sum(prime[:n]))

Python: import sys
inputs = sys.stdin.readlines()
A = [int(i.rstrip('\n')) for i in inputs]
B = sorted(A)
m = B[-1]

P = [2, 3, 5, 7]
for i in range(11, m + 1, 2):
    if i % 5 == 0 or i % 7 == 0:
        continue
    is_prime = True
    for p in P:
        if p * p > i:
            break
        if i % p == 0:
            is_prime = False
            break
    if is_prime:
        P.append(i)
P.append(1000000)

l = len(P)
for a in A:
    for i in range(l):
        if P[i] > a:
            print(i)
            break

Python: from sys import stdin

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

Python: limit = int(input(""))
def primeNumber(number):
    count = 0
    for i in range(2,number+1):
        if (number%i==0):
            count = count + 1
    if (count==1):
        return True
    else:
        return False

sum = 0
for i in range(2,limit+1):
    if (i<2):
        break
    if (primeNumber(i)):
        sum = sum + 1

print(sum)

Python: lst = [1 for i in range(10 ** 6 + 1)]
lst[0] = lst[1] = 0
for i in range(10 ** 6 + 1):
  if lst[i] == 1:
    for j in range(i * 2, 10 ** 6 + 1, i):
      lst[j] = 0
while 0 == 0:
  try:
    n = int(input())
    c = 0
    for i in range(n + 1):
      c += lst[i]
    print(c)
  except EOFError:
    break