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

C++: #include<iostream>

int main(){

	bool data[100001];

	for (int i = 0; i < 100001; i++)
		if (i!=2&&i % 2 == 0)
			data[i] = false;
		else
			data[i] = true;

	int in;

	for(int i=2;i<=100000;i++){
		if (i==2||i % 2 != 0) {
			for (int j = 2; j < i; j++) {
				if (i%j == 0) {
					data[i] = false;
					goto fl;
				}
			}
		}
	fl:;
	}

	while (true) {

		std::cin >> in;

		int res = 0;

		for (int i = 2; i <= in; i++) {
			if (data[i] == true)
				res++;
		}

		std::cout << res << std::endl;

	}

		return 0;
}

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

using namespace std;


int main() {
	int n;
	bool p[1000000];

	p[0] = 0;
	p[1] = 0;

	for(int i = 2; i <= 999999; i++) {
		p[i] = true;
	}

	for(int i = 2; i * i <= 999999; i++) {
		for(int j = i; j * i <= 999999; j++) {
			p[j * i] = false;
		}
	}

	while(cin >> n) {
		int count = 0;
		for(int i = 2; i <= n; i++) {
			if(p[i] == true) {
				count++;
			}
		}

		cout << count << endl;
	}
}

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

int main() {
  cin.tie(0);   //cinとcoutとの結びつきの解除をする
  ios::sync_with_stdio(false);    //stdioとの同期を解除する

  int x;
  int count_cin = 0;
  while(true){
    cin >> x ;
    count_cin++;

    if(count_cin == 30) break;


    bool array[max_n];

    for(int i = 0; i < max_n; i++) {
      array[i] = true;
    }

    array[0] = false;
    array[1] = false;
    for(int i = 2; i < max_n; i++) {
      for(int j = 2; j < max_n; j++) {
        if(i * j > max_n) break;
        array[i * j] = false;
      }
    }

    int count_sosu = 0;

    for(int i = 0; i < x; i++) {
      if(array[i] == true) count_sosu++;
    }

    cout << count_sosu << endl;
  }

}

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

typedef long long LL;
using namespace std;

const int X = 1000001;
bool Find[X];

void init(){
  for(int i=0;i<X;i++){
    Find[i] = false;
  }
  for(int i=2;i<=sqrt(X);i++){
    if(Find[i])continue;
    for(int j=i+1;j<X;j++){
      if(Find[j])continue;
      if(j%i==0)Find[j]=true;
    }
  }
}

int main(){
  init();
  int n;
  while(cin >> n){
    int answer = 0;
    for(int i=2;i<n+1;i++){
      cout << Find[i] <<endl;
      if(!Find[i])answer++;
    }
    cout << answer << endl;
  }
  return 0;
}

C++: 
#include<iostream>
#pragma warning(disable:4996)
using namespace std;
int n,t;
int d[10000000];
bool is_prime(int n){
	for (int i = 2; i*i <= n; i++)
	if (n%i == 0)   return false;   return true;

}
int main(){
	for (int i = 0; i < 10000000; i++)
		d[i] = 1;
	for (int i = 2; i<100; i++){
		if (is_prime(i))
		{
			int j = 2;
			while (i*j < 10000000){
			     d[i*j] = 0;
				j++;
			}
		}}
	while (scanf("%d", &n) != EOF){
		t = 0;
		for (int i = 2; i <= n; i++){
			if (d[i] == 1)
				t++;
		}
		cout << t << endl;

	}


}

C++: #include <iostream>
using namespace std;
const int MAX_V = 1000000; // 100????????§?´???°??¨?????????
const int prime[MAX_V+1]; // 1????´???°???0????´???°??§?????? 
const pcount[MAX_V+1];
int main() {
    int i, k,a,sum=0;
    for(i = 2; i <= MAX_V; i++) {
        prime[i] = 1; // 2??\????´???°??¨??????
    } 
    for(i = 2; i*i <= MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0; // ?´???°2?????\????????°?´???°??§?????? 
            }
            
        } 
        
    }
    pcount[0]=0;
    pcount[1]=0;
    for(i=2;i<MAX_V;i++){
        if(prime[i]){
            sum++;
        }
        pcount[i]=sum;
    }
    for(i=0;i<30;i++){
        scanf("%d",&a);
        printf("%d\n",pcount[a]);
    } 

    return 0; 
    
}

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

using namespace std;

bool prime_check(int n)
{
	if (n == 1)
	{
		return false;
	}
	else if (n == 2)
	{
		return true;
	}
	else
	{
		for (int i = 2; i <= sqrt(n); i++)
		{
			if (n % i == 0)
			{
				return false;
			}
		}
	}

	return true;
}

int main()
{
	// --- variable define --- //

	int n, c;


	// --- prime check ( 2 to 999 ) --- //

	bool isprime[1000];

	for (int i = 1; i < 1000; i++)
	{
		if (prime_check(i) == true)
		{
			isprime[i] = true;
		}
		else
		{
			isprime[i] = false;
		}
	}


	// --- main --- //

	while (cin >> n)
	{
		c = 0;

		for (int i = 2; i <= n; i++)
		{
			if (i <= 999)
			{
				if (isprime[i] == true)
				{
					c += 1;
				}
				else
				{
					c += 0;
				}
			}
			else
			{
				for (int j = 2; j <= sqrt(i); j++)
				{
					if (n % i == 0)
					{
						c += 0; goto Exit;
					}
				}

				c += 1;
			}
		Exit:;
		}

		cout << c << endl;
	}
}

C++: #include<stdio.h>
int main(void)
{
    int n,i,j,z,x;
	
    scanf("%d",&n);
	for(n!=1){
		for(i=2;i<=n;i++){
			z=0;
			for(j=2;j<=i;j++){
				if(i%j==0 && i!=j){
					z++;
					break;
				}
			}
			if(z==0){
				x++;
			}
		}
		printf("%d\n",x);
		scanf("%d",&n);
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-9


bool primes[1000000];

void make_prime(){
	for(int i=2; i<1000000; i++)primes[i]=true;
	for(int i=2; i*i<=1000000; i++)
		for(int j=i*2; j<1000000; j+=i)primes[j]=false;
}

int main(){
	int n,ret;
	make_prime();
	while(~scanf("%d",&n)){
		ret = 0;
		for(int i=2; i<=n; i++)if( primes[i] )ret++;
		printf("%d\n",ret);
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#define MAX 1000000
using namespace std;
int main(){
    vector<int> v(MAX);
    for(int i = 0;i<MAX;i++)
      v[i]=true;

      v[0]=false;
      v[1]=false;
    for(int i = 2;i<MAX;i++){
      if(v[i]){
        for(int j =i*i;j<MAX;j+=i){
         v[j]=false;
       }
      }
    }
    for(int i = 2;i<MAX;i++)v[i]+=v[i-1];
    while(true){
      int a;
      cin >> a;
      if(cin.eof())return 0;
      cout << v[a]<<endl;
    }
}

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

const int m=500000;
int prime[m];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    for(int i=0; i<m; i++) prime[i]=1;
    for(int i=3; i<1000; i+=2) {
        if(!prime[i>>1]) continue;
        for(int j=(i*i)/2; j<m; j+=i) prime[j]=0;
    }
    for(int i=1; i<m; i++) prime[i]+=prime[i-1];
    int n;
    while(cin>>n) {
        cout<<prime[(n-1)/2]<<'\n';
    }
    return 0;
}

C++: #include <stdio.h>

int main(){
    int n,in,count,i,j;
    char era[1000000];

    scanf("%d",&in);

    for(i=0;i<=in;i++){
        era[i]=1;
    }

    count=0;
    for(i=2;i<=in;i++){
        if(era[i] == 1){
            count++;
            for(j=i;j<=in;j+=i){
                era[j]=0;
            }
        }
    }
    printf("%d\n",count);

    return 0;
}