Go: package main

// https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}
		maybePrime := make([]bool, n+1)
		for i := 0; i <= n; i++ {
			maybePrime[i] = true
		}

		maybePrime[0] = false
		maybePrime[1] = false
		for i := 2; i <= int(math.Sqrt(float64(n)))+1; i++ {
			j := i * 2
			for j <= n {
				maybePrime[j] = false
				j += i
			}
		}

		nPrimes := 0
		for _, p := range maybePrime {
			if p {
				nPrimes++
			}
		}
		// fmt.Println(maybePrime)
		fmt.Println(nPrimes)
	}
}

C++: #include <iostream>
#include <list>
#include <algorithm>

using namespace std;

int main() {
  int n;
  
  while(!cin.eof()) {
    cin >> n;
    list<int> search_list(n-1);
    list<int> prime_number;
    while(n!=1) {
      if(n%2 != 0) 
	search_list.push_front(n);
      n--;
    }
    
    while(!search_list.empty()) {
      int m = search_list.front();
      prime_number.push_back(m);
      search_list.pop_front();
      list<int>::iterator it = search_list.begin();
      while(it!=search_list.end()) {
	if((*it % m) == 0){
	  it = search_list.erase(it);
	  continue;
	}
	it++;
      }				   
    }
    cout << prime_number.size()+1 << endl;
    prime_number.clear();
    search_list.clear();
  }
}

C++: #include <iostream>
#include <cstdio>

using namespace std;

int furui(int N){
  int i;
  int count=0;
  int array[1000000];
  array[0]=false;
  array[1]=false;
    
  for(i=2;i<=N;i++){
    array[i]=true;
  }

  for(i=2;i*i<=N;i++){
    if(array[i]==true)for(int j=i*i;j<=N;j+=i){
	array[j]=false;
      }
  }

  for(i=2;i<=N;i++){
    if(array[i]==true)count++;
  }

  return count;
}

int main(){
  int cnt=0,n;
  while(cnt<30){
    cnt++;
    cin >> n;
    cout << furui(n) <<endl;
}

  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
typedef long long LL;
using namespace std;
#define REPF( i , a , b ) for ( int i = a ; i <= b ; ++ i )
#define REP( i , n ) for ( int i = 0 ; i < n ; ++ i )
#define CLEAR( a , x ) memset ( a , x , sizeof a )
const int N=1e7;
int sum[N];
bool vis[N];
void initPrime()
{
    int num = 0, m = sqrt (N + 0.5);
    for (int i = 2; i <= m; ++i)
        if (vis[i] == 0)
            for (int j = i * i; j <= N; j += i) vis[j] = 1;
    sum[1]=0;
    for(int i=2;i<=N;i++)
    {
        if(!vis[i])  sum[i]=sum[i-1]+1;
        else   sum[i]=sum[i-1];
    }
//    for(int i=2;i<=10;i++)
//        cout<<"233  "<<sum[i]<<endl;
}
int main()
{
    int n;
    initPrime();
    while(~scanf("%d",&n))
        printf("%d\n",sum[n]);
    return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;

const int MAX_N = 999999;
bool prime[MAX_N + 1];

void sieve()
{
  prime[0] = prime[1] = false;
  for(int i = 2; i <= MAX_N; ++i)
    prime[i] = true;
  for(int i = 2; i <= MAX_N; ++i)
    if(prime[i])
      for(int j = i * 2; j <= MAX_N; j += i)
	prime[j] = false;
}

int is_prime(int n)
{
  return prime[n];
}

int main()
{
  int n, i;
  int ans = 0;
  sieve();
  while(cin >> n){
    for(i = 0; i < n; i++){
      if(is_prime(i)){
	ans++;
      }
    }
    if(i == n){
      break;
    }
  }
  printf("%d\n", ans);
}

C++: #include <iostream>
using namespace std;

int main(){
	int n,w=1;
	while (cin >> n) {
		
		for(int j=n;j>1;j--){
			for(int i=2;i<j;++i){
				if(j%i == 0){
					break;
				}
				if(i==j-1){
	//				cout << j << endl;
					w++;
				}
			}
		}
		cout << w << endl;
		w = 1;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;

int main() {
	int n, ans; bool check;
	while (cin >> n) {
		ans = 0;
		for (int i = 1; i <= n; i++) {
			if (i <= 3) {
				if (i != 1) { ans++; } continue;
			}
			else {
				if (i % 2 == 0 || i % 3 == 0) continue;
				if (i % 6 != 1 && i % 6 != 5) continue;
				check = true;
				for (int j = 5; j * j <= i; j += 6) {
					if (i % (j + 0) == 0) { check = false; }
					if (i % (j + 2) == 0) { check = false; }
					if (check == false) { break; }
				}
				if (check == true) ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <math.h>
using namespace std;

int main(){
  int a;
  int i, j, k;
  int past=1, a_sqrt;
  int count;
  bool chk[1000000];

  for(i=1; i<1000000; i++) chk[i]=true;
  while(cin>>a){
    count=0;
    if(past>=a){
      for(i=2; i<=a; i++){
        if(chk[i]) count++;
      }
      printf("%d\n", count);
    }
    else {
      a_sqrt=(int)sqrt((double)a);
      for(i=2; i<=a_sqrt; i++){
        for(j=i; j<=a/i; j++){
          chk[j*i]=false;
        }
      }
      past=a;
      for(i=2; i<=a; i++){
        if(chk[i]) count++;
      }
      printf("%d\n", count);
    }
  }

  return 0;
}

C++: #include<iostream>
#include<vector>

using namespace std;
   
void primeCal()
{
    const int N = 1000000;
    
    vector<bool> prime(N, true);
    prime[0] = prime[1] = false;
    
    vector<int> count(N);
    
    int n;
    
    for (int i = 2; i*i < N; ++i) 
    {
        if (!prime[i]) 
        { 
            continue; 
        }
        
        for (int j = i*i; j < N; j += i) 
        {
            prime[j] = false;
        }
    }
    
    for (int i = 1; i < N; ++i) 
    {
        count[i] = count[i-1] + prime[i];
    }
    
    while (cin>>n)
    {
        cout << count[n] << endl;
    }
    
    return;
}
     
int main()
{     
    primeCal();
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int a,n,i,j;
	
	while(cin>>a){
	n=0;
	for(i=2;i<=a;i++){
		for(j=2;j<i;j++){
			if(i%j==0)break;
		}
		if(i == j) n += 1;
	}
	cout<<n<<endl;
	n=0;
	}
	
}

C++: #include <iostream>
#include <cstring>
using namespace std;

int prime[1000000];

int main()
{
  int n;
  for (int i = 0; i < 1e6; i++) prime[i] = 1;
  prime[0] = prime[1] = 0;
  for (int i = 2; i < 1000000; i++){
    if (prime[i] == 1){
      for (int j = 2 * i; j < 1000000; j += i){
        prime[j] = 0;
      }
    }
  }
  for (int i = 0; i < 1000000; i++){
    prime[i + 1] += prime[i];
  }
  while (cin >> n){
    cout << prime[n] << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
bool isprime(int n) {
	if (n == 2)return true;
	if (n % 2 == 0)return false;
	for (int i = 3; i <= sqrt(n); i += 2) if (n%i == 0)return false;
	return true;
}
int main() {
	long prime[80000];
	prime[0] = 2;
	int num = 1;
	for (int i = 3; i < sqrt(1000000); i += 2) {
		if (isprime(i)) {
			prime[num] = i;
			num++;
		}
	}
	long n; while (cin >> n) {
		int j = 0;
		for (; prime[j] <= n; j++) {}
		cout << j << endl;
	}
	return 0;
}

C++: #include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

bool table[1000000];
vector<int> primes;

int main() {
  table[2] = true;
  for (int i = 3; i <= 999999; i += 2)
    table[i] = true;
  for (int i = 3; i <= 1000; i += 2)
    if (table[i])
      for (int j = 3 * i; j <= 999999; j += 2 * i)
        table[j] = false;
  primes.push_back(2);
  for (int i = 3; i <= 999999; i += 2)
    if (table[i])
      primes.push_back(i);
  int n;
  while (scanf("%d", &n) == 1) {
    printf("%d\n", upper_bound(primes.begin(), primes.end(), n)-primes.begin());
  }
  return 0;
}

C++: #include <iostream>
using namespace std;

int main()
{
	unsigned int  n;
	cin >> n;
	unsigned  int num,count = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> num;
		for(int j = 2; j <=num; j++)
		{
			if(num == j)count++;
			if((num % j) == 0)
			{
				break;
			}
		}
	}
	cout << count << endl;
	return 0;
}