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)
	}
}

C++: #include<iostream>
using namespace std;
int main(){
	int n;
	bool array[1000000];
	while(cin>>n){
		int count=0;
		array[0]=array[1]=false;
		for(int i=1;i<=n;i++){
			if(array[i]){
				count++;
				for(int j=i*2;j<=n;j+=i){
					array[j]=false;
				}
			}
		}
		cout<<count<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX_N = int(1e6);

int main(){

    int n, i, j, maxin = 2;
    bool jud;
    vector <int> vec;
    for (i = 2; i <= MAX_N; i++){
        jud = 0;
        for (j = 0; j < vec.size(); j++){
            if (vec[j] * vec[j] > i) break;
            if (!(i % vec[j])){
                jud = 1;
                break;
            }
        }
        if (!jud)
            vec.push_back(i);
    }
    while (cin >> n){
        cout << upper_bound(vec.begin(), vec.end(), n) - vec.begin() << endl;
    }
}

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

bool check(int in){
	for (int i = 3; i<=sqrt(in); i+=2){
		if (i != 5 && i % 5 == 0)	continue;
		if (in % i == 0)
			return false;
	}
	return true;
}

int PrimeNumber(int in, int start){
	int count = 0;
	if (in > 2)	count++;
	for (int i = start; i <=in; i+=2){
		if (check(i))	count++;
	}

	return count;
}

int main(){
	int in, count500000 = PrimeNumber(500000, 3);

	while (cin >> in, !cin.eof()){
		if (in <= 500000)
			cout << PrimeNumber(in, 3) << endl;
		else
			cout << count500000 + PrimeNumber(in, 500001) << endl;
	}
}

C++: #include <iostream>

using namespace std;

int isprime(int x){
	if(x < 2){
		return false;
	}else{
		for(int i=2;i<x;i++){
			if(x%i==0){
				return false;
			}
		}
		return true;
	}
}
int main(){
	int n;
	cin >> n;
	int a = 0;
	for(int i=2;i<=n;i++){
		if(isprime(i)){
				a++;
		}
	}
				cout << a << endl;
				return 0;
}

C++: #include <iostream>

using namespace std;
int main()
{
    long long n;
    long long prime = 0;

    cin >> n;
    
    for(int x=1; x<=n; x++)
    {
            int counter = 0;
            for(int y=1; y<=x; y++)
            {
                    if(x%y==0)
                    counter++;
            }
            
            if(counter==2)
            {
                    prime++;
            }
    }
    
    cout << prime << endl;
    
return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void) {
	long long int n;
	while (cin >> n) {
		int m = 0;
		long long int prime[2000000];
		bool is_prime[2000000];
		for (int i = 0; i <= n; i++) {
			is_prime[i] = true;
		}
		is_prime[0] = is_prime[1] = false;
		for (int i = 2; i <= n; i++) {
			if (is_prime[i]) {
				m++;
				for (int j = i * 2; j <= n; j += i) {
					is_prime[j] = false;
				}
			}
		}
		cout << m << endl;
	}
	return 0;
}

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

int main(void)
{
    long num, length, prime[1000];

    while(cin >> num)
    {
        length = 0;
        int count = 0;
        for (int n = 2; n <= num; n++)
        {
            bool isPrime = true;
            for(int i=0; i < length-1; i++)
            {
                if (!(n % prime[i]))
                {
                    isPrime = false;
                    break;
                }
            }
            if (isPrime)
            {
                prime[length] = n;
                length++;
            }
        }
        cout << length << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
        int prime[40];
        bool is_prime[40];
        int i=2,j=2,n,count=0;
        while(scanf("%d",&n) != EOF){
                int p = 0;
                for(i = 0;i <= n; i++){
                        is_prime[i] = true;
                }
                is_prime[0]=is_prime[1]=false;
                for(i = 2; i<=n;i++){
                        if(is_prime[i]){
                                prime[p++] = i;
                                for(j = 2*i; j <= n; j+=i) is_prime[j] = false;
                        }
                }
                cout << p << endl;
        }
        return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
#define MAX 100

bool prime[MAX]={};

void run(){
  for(int i=2;i<MAX;i++){
    prime[i]=true;
  } 

  for(int i=2;i<MAX;i++){
    if(!prime[i])continue;
    for(int j=2;j*i<MAX;j++){//i*1 is prime number
      prime[i*j]=false;
    }
  }
  return;
}

int main(){

  run();
  
  int n;
  while(cin>>n){
    int sum=0;
    for(int i=2; i<=n; i++){
      if(prime[i])sum++;
    }
    cout<<sum<<endl;
  }
  return 0;

}

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

#define LIM 1000000
using namespace std;

void prime();

vector<int> prime_map;

int main(){
  int num, i=0,j=0;
  vector<int> count;
  prime();
  cout<<"plese"<<endl;
  while(cin){
    cin>>num;
    i=0;
    while(prime_map[i]<=num){
      i=i+1;
    }
    count.push_back(i);
    j++;
  }

  i=0;
  while(i<j){
    cout<< count[i]<<endl;
    i++;
  }
}

void prime(){
  bool judge;
  for(int i = 2; i <= LIM;i++){
    judge=1;
    for(int j= 2; j < i/2; j++){
      if(i%j == 0)judge = 0 break;
    }
    if(judge == 1)prime_map.push_back(i);
  }
}

C++: #include<iostream>
using namespace std;
int main(){
	int a,o=0;
	bool n[1000000];
	for(int i=2;i<=999999;i++){
		n[i]=true;
	}
	n[0]=n[1]=false;
		for( int j=2;j*j<=999999;j++){
			if(n[j]){
				for(int k=j*2;k<=999999;k+=j){
				n[k]=false;
				}
			}
		}
		while(cin>>a){
	for(int k=2;k<=a;k++) if(n[k]) o++;
	cout<<o<<endl;
	o=0;
		}
}

C++: #include <stdio.h>

const int MAX_V = 1000000;
int prime[MAX_V+1];

void init(){
    int i, k, v;
    for(i=2; i<MAX_V; i++){
        prime[i] = 1;
    }
    for(i=2; i*i<=MAX_V; i++){
        if(prime[i]){
            for(k=2*i; k<=MAX_V; k+=i){
                prime[k]=0;
            }
        }
    }
}

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

int main(){
    init();
    int num;
    while(scanf("%d", &num) != EOF){
        int count=0;
        for(int i=2; i<=num; i++){
            if(isprime(i)==1)
                count++;
        }
    printf("%d\n", count);
    }
    return 0;
}