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>
using namespace std;

int main()
{
	int n = 0, x = 0;
	int countdata[1000];
	while (cin >> n) {
		int count = 0;
		for (int a = 2; a <= n; a++) {
			if (a % 2 != 0 && a % 3 != 0 && a % 5 != 0 && a % 7 != 0) 
				count++;
			if (a == 2 || a == 3 || a == 5 || a == 7)
				count++;
		}
		countdata[x] = count;
		x++;
	}
	for (int a = 0; a < x; a++) {
		cout << countdata[a] << endl;
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
static const double EPS = 1e-10;

int main(){
	vector<int> p;
	bool b;
	int n;

	while(cin >> n){
		p.clear();
		if(n > 1){
			p.push_back(2);
			for(int i = 3; i <= n; i++){
				b = true;
				for(int j = 0; j < p.size(); j++){
					if(p[j]*p[j] > i){
						break;
					}
					if(i % p[j] == 0){
						b = false;
						break;
					}
				}
				if(b){
					p.push_back(i);
				}
			}
		}
		cout << p.size() << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
#define MAX 1000000
int main( void )
{
	vector <bool> primes(MAX+1, false);

	for ( int i = 3; i <= MAX; i += 2 )
	{
		primes[i] = true;
	}

	for ( int i = 3; i <= MAX; i += 2 )
	{
		if ( primes[i] )
		{
			for ( int j = i + i; j <= MAX; j += i )
			{
				primes[j] = false;
			}
		}
	}

	int n;
	cin >> n;

	int c = 0;
	if ( n == 2 )
		c = 1;
	else if( n < 2 )
		c = 0;
	else
	{
		c = 1;
		for ( int i = 3; i <= n; i += 2 )
		{
			if ( primes[i] )
				c++;
		}
	}

	cout << c << endl;

	return 0;
}

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

int primes[1000000]={0};


int main(){
    primes[0] = -1;
    primes[1] = -1;
    for(int i=2; i<1000; i++){
        if(primes[i]==-1) continue;
        for(int j=i+1; j<1000000; j++){
            if(j%i==0) primes[j] = -1;
        }
    }
    puts("hoge");
    int n;
    while(-1!=scanf("%d", &n)){
        int ans = 0;
        for(int i=2; i<=n; i++){
            if(primes[i] == 0) ans++;
        }
        cout << ans << endl;
    }
}

C++: #include<iostream>
#include<stdio.h>

using namespace std;

int ans = 0;

void Prime_number(int n){
	int i;
	int prime_num;

	for(i = 2; ; i++){
		if(n % i == 0 && n != i){
			break;
		}else if(n == i){
			ans++;
			break;
		}
	}

	if(n != 2){
		Prime_number(n-1);
	}
}

int main(){
	int n;

	while((scanf("%d",&n)) != EOF){
		Prime_number(n);
		cout << ans << endl;
		ans = 0;
	}

}

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

using namespace std;

int main()
{
    int n;
    int prime[800];
    int ptr = 0;

    prime[ptr++] = 2;
    prime[ptr++] = 3;

    while (cin >> n) {
        if (n == 2) {
            cout << "1\n";
            continue;
        }
        else if (n == 3) {
            cout << "2\n";
            continue;
        }

        int count = 2;        
        for (int i = 5; i <= n; i += 2) {
            bool flag = false;
            for (int j = 1; prime[j] * prime[j] <= i; j++) {
                if (!(i % prime[j])) {
                    flag = true;
                    break;
                }
            }
            if (!flag) {
                prime[ptr++] = i;
                count++;
            }
        }
        cout << count << "\n";
    }
    
    return 0;
}

C++: #include <stdio.h>
#include <ctype.h>

int main (void){
	int number, i, j, count=0;
	
	while(scanf("%d", &number)!=EOF){
	count=0;
	int n[number];
	for(i=0; i<number; i++){
		n[i]=i;
	}
	
	for(i=0; i<number; i++){
		j=i;
		while(1){
			j+=i;
			if(j>number){break;}
			n[j]=-1;
			if(i==0 || i==1){
				n[i]=-1;
				break;
			}
		}
	}
	
	for(i=0; i<number; i++){
		if(n[i]!=-1){
			//printf("%d\n", n[i]);
			count++;
		}
	}
	printf("%d\n", count+1);
	}
	
	return 0;
}

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

bool f(int n)
{
     bool flag = true;
     for(int j=2; j<n; j++)
     {
         if(n%j == 0)
             flag = false;
     }
     if (flag == true)
         return 1;
     else
         return 0;
}

int main()
{
    int n, sum;
        
    while(cin >> n)
    {
        sum = 1;
        if(n<2)
            cout << 0;
        else if(n==2)
            cout << 1;
        else
        {
            for(int i=3; i<=n; i++)
                if(f(i))
                    sum++;
            
            cout << sum;
        }
        cout << endl;
    }
    
    return 0;
}

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

vector<char> sieve(const int M){
    vector<char> isPrime(M);
    for(int i=2;i<M;i++) isPrime[i] = true;
    for(int i=2;i*i<M;i++){
        if(not isPrime[i]) continue;
        for(int j=i*i;j<M;j+=i){
            isPrime[j] = false;
        }
    }
    return isPrime;
}

int main (int argc, char const* argv[])
{
    int n;
    vector<char> p;
    while(cin >> n){
        int count = 0;
        p = sieve(n+1);
        for(vector<char>::iterator it = p.begin(); it != p.end() ; ++it){
            if(*it == true)
                ++count;
        }
        
        cout << count << endl;
    }
    return 0;
}