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<cstdio>
#include<cmath>
using namespace std;

int main(){
  int n,prime[1000001],key,lf=0;
  prime[0]=2;
  key=1;
  for(int i=3;i<=1000000;i+=2)
    {
      for(int j=2;j<=sqrt(i);j++)
	{
	  if(i%j == 0)
	    {
	      lf=1;
	      break;
	    }
	}
      if(lf == 1)
	{
	  lf=0;
	}
      else 
	{
	  prime[key]=i;
	  key++;
	}
    }

  while(cin >> n)
{
  int cou=0;
  for(int i=0;;i++)
    {
      if(prime[i] <= n)
	{
	  cou++;
	}
      else break;
    }

  cout << cou << endl;
 }
}

C++: #include<iostream>
#include<cmath>
using namespace std;
bool isPrime(int x)
{
	if (x < 2)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	for (int i = 3; i <= (int)sqrt(x); i+=2)
		if (x%i == 0)
			return false;
	return true;
}
int main()
{
	int n;
	cin >> n;
	int count = 0;
	for (int i = 1; i <= n; i++)
		if (isPrime(i))
			count++;
	cout << count << endl;
}

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 == 0)
			{
				break;
			}
			if(num - 1 == j)
			{
				count++;
			}
		}
		if(num == 2)
		{
			count++;
		}
	}
	cout << count << std::endl;
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	bool num[1000000] = {0};
	for(int i=2; i<1000; i++){
		if(!num[i]){
			for(int j=i*2; j<1000000; j+=i){num[j] = true;}
		}
	}
	int n;
	while(cin >>n){
		int f = 0;
		for(int i=2; i<=n/2+1; i++){
			if(!num[i]){f++;}
		}
		cout <<f<<endl;
	}
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main (){
    
    /*?´???°???????´?????????????*/
    vector<int>Primenumber(MAX+1,0);
    /*?´???°???????´???????????????????*/
    int n;
    while(cin >> n){
        bv check(MAX+1,true);
    for(int i = 2; i<=n;i++){
        if(check[i]){
            /*true?????£?????¨???????????°????????????false??§*/
            for(int j = 2;i*j<=n;j++)
                check[i*j] = false;
        }
    }
    int ans = 0;
    for(int i = 2;i<=n;i++)
        if(check[i])
            ans++;
    cout << ans << endl;
    }
}

C++: #include"stdio.h"
#define nmax 1000000
int ans[nmax];
bool is_prime[nmax + 1];

void sieve(int n) {
	int p = 0;
	for (int i = 0; i <= n; i++)is_prime[i] = true;
	is_prime[0] = is_prime[1] = 0;
	ans[0] = ans[1] = 0;
	for (int i = 2; i <= n; i++) {
		if (is_prime[i]) {
			p++;
			for (int j = 2 * i; j <= n; j += i)is_prime[j] = false;
		}
		ans[i] = p;
	}
}
int main()
{
	sieve(nmax);
	int n,m=0;
	for (; scanf("%d", &n) == 1;) {
		printf("%d\n", ans[n]);
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int prime[100000] = {0};

void makeprime(long long int n)
{
    int k = 1;
    prime[0] = 2;
    for (long long int i = 3; i < n; i++)
    {
        double temp = sqrt(i);
        for (int j = 0; i % prime[j] != 0; j++)
        {
            if (temp < prime[j])
            {
                prime[k++] = i;
                break;
            }
        }
    }
    // rep(i,1000){
    //     cout<<prime[i]<<" ";
    // }
}

int main()
{
    makeprime(999999);
    int n;
    int i;
    while (cin >> n)
    {
        i = 0;
        while (true)
        {
            if (n < prime[i])
            {
                break;
            }
            i++;
        }
        cout << i << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int m,i,k,n;
	while(cin>>n)
	{
		int j=0;
		for(m=2;m<=n;m++)
		{
		    k=int(sqrt(double(m)));
		    i=2;
		    while(m%i&&i<=k)
				i++;
			if(i>k)
				j+=1;
		}
		cout<<j<<endl;
	}
	return 0;
}

C++: #include<stdio.h>
#include<math.h>
int a[20000];
int main()
{
    int i, j, q, n, co;
    while(scanf("%d",&n)==1)
    {
        co=0;
        a[0]=1;
        a[1]=1;
        for(i=4 ; i<=n ; i+=2)
        {
            a[i]=1;
        }
        q=sqrt(n);
        for(i=3 ; i<=q ; i+=2)
        {
            if(a[i]==0)
            {
                for(j=i*i ; j<n ; j+=i)
                {
                    a[j]=1;
                }
            }
        }
        for(i=0 ; i<=n ; i++)
        {
            if(a[i]==0)
            {
                co++;
            }
        }
        printf("%d\n",co);
    }
    return 0 ;
}