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 <stdio.h>
#include <stdlib.h>
#include <string.h>

#pragma warning(disable:4996)

int main()
{
	int DataSet,nCnt,nCnt2,In,Total,Count;

	Total = 0;
	DataSet = 0;


	for (DataSet = 0; DataSet <= 30; DataSet++)
	{
		scanf("%d", &In);
		Total = 0;
		for (nCnt = 2; nCnt <= In; nCnt++)
		{
			Count = 0;
			for (nCnt2 = nCnt; nCnt2 >= 2; nCnt2--)
			{
				if (nCnt%nCnt2 == 0)
				{
					if (nCnt != nCnt2)
					{
						Count++;
						break;
					}
				}
			}
			if (Count == 0)
				Total++;
		}
		printf("%d\n", Total);
	}

	return 0;
}

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

using namespace std;

int main()
{
    int n;
    const int max_index = 1000000;
    int prime[max_index];

    prime[0] = 0;
    for (int i = 1; i < max_index; i++) 
        prime[i] = 1;

    for (int i = 1; i < (int)sqrt(max_index); i++) {
        if (prime[i] == 1)
            for (int j = i + 1; (i + 1) * j <= max_index; j++)
                prime[(i + 1) * j - 1] = 0;
    }

    int tmp = 0;
    for (int i = 0; i < max_index; i++) 
        (prime[i] == 0) ? (prime[i] = tmp) : prime[i] = ++tmp;
    prime[0] = 0;

    while (cin >> n) 
        cout << prime[n - 1] << endl;
    
    return 0;
}

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

using namespace std;

int main()
{ 
	int n;
	while (cin >> n)
	{
		vector<bool> a(n + 1, true);
		int cnt = n == 0 ? 0 : n - 1;

		// Sieve of Eratosthenes
		for (int i = 2; i*i <= n; ++i)
			if (a[i])
				for (int j = 0; i * (j + 2) <= n; ++j)
					if (a[i * (j + 2)]) a[i * (j + 2)] = false, cnt--;

		cout << cnt << endl;
	}

	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;

int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };


int main(){
	ios::sync_with_stdio(false);

	int n;
	int count;
	int nmax = 1000000;
	vector<bool> flag(nmax+1, true);

	flag[0] = !flag[0];
	flag[1] = !flag[1];

	for (int i = 2; i <= sqrt(nmax) + 1; i++){
		if (flag[i]){
			for (int j = i * 2; j <= nmax; j += i){
				flag[j] = false;
			}
		}
	}
	
	while (cin >> n){
		count = 0;
		for (int i = 0; i <= n; i++){
			if (flag[i])
				count++;
		}

	printf("%d\n", count);
	}

}

C++: /*
	大号水?，拿来?手
*/
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;

int Find_Number (int x)
{
	int cnt = 0;
	for (int i=2;i<=x;i++)
	{
		bool flag = false;
		for (int j=2;j<=sqrt((double)i);j++)
		{
			if ( i % j == 0)
			{
				flag = true;
				break;
			}
		}
		if (flag == false )
		{
			cnt++;
		}
	}
	return cnt;
}

int main ()
{
	int N;
	while (scanf("%d",&N)!=EOF)
	{
		cout<<Find_Number (N)<<endl;
	}
	return 0;
}

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

bool isprime(int number, std::vector<int> const& primeset)
{
	int maxprime = static_cast<int>(std::sqrt(static_cast<float>(number)));

	typedef std::vector<int>::const_iterator Iter;
	Iter primesetlimit = std::upper_bound(primeset.begin(), primeset.end(), maxprime);
	for (Iter p = primeset.begin(); p != primesetlimit; ++p) {
		if (number % *p == 0) {
			return false;
		}
	}
	return true;
}

int resolve(int number)
{
	if (number < 2) {
		return 0;
	}
	if (number == 2) {
		return 1;
	}
	std::vector<int> primesetExceptTwo;
	for (int i = 3; i <= number; i += 2) {
		if (isprime(i, primesetExceptTwo)) {
			primesetExceptTwo.push_back(i);
		}
	}
	if (isprime(number, primesetExceptTwo)) {
		primesetExceptTwo.push_back(number);
	}
	return static_cast<int>(primesetExceptTwo.size()) + 1;
}

int main()
{
	int input;
	while (std::cin >> input) {
		std::cout << resolve(input) << std::endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    vector<int> v;
    v.resize(n + 1);
    fill(v.begin(), v.end(), 1);
    v[0] = 0;
    v[1] = 0;
    for (int i = 0; i * i * i * i < v.size(); ++i) {
      while (v[i] == 0) ++i;
      for (int m = i + 1; m < v.size(); ++m) {
        if (m % i == 0) {
          v[m] = 0;
        }
      }
    }
    cout << accumulate(v.begin(), v.end(), 0) << endl;
  }
  return 0;
}

C++: #include<stdio.h>

int main(void)
{
	int data,i,j,k=0,l=0,kai[1000]={0},s[1000000]={0};

	while(scanf("%d",&data) != EOF)
	{
		if(data<=1)
		   kai[k]=0;
		else
		{
			for(i=2;i<=data;i++)s[i]=i;

		    i=2;
			while(i*2<data)
			{
			  if(s[i] != 0)
			  {  
				 j=2;
				while(j*i<=data)
				{
					s[j*i]=0;
					j+=1;
				}
			  }
			  i+=1;
			}

			
			for(i=2;i<=data;i++)
			{	
				if(s[i]!=0)
				{
					kai[k]+=1;
				}
			}
		}
		k+=1;
	}

  for(i=0;i<k;i++)
	  printf("%d",kai[i]);

  return 0;
}

C++: #include <cstdio>
#define N 999999
unsigned char p[((N+1)/2+7)/8];
int main() {
    int i,j,s,n=3;
    for(i=0;n*n<=N;i++,n+=2)
        if(!(p[i/8]&(1<<(i%8))))
            for(j=i+n;j<((N+1)/2);j+=n)p[j/8]|=(1<<(j%8));
    while(scanf("%d",&n)!=EOF) {
        if(n<2){printf("0\n");continue;}
        if(n==2){printf("1\n");continue;}
        for(i=3,j=0,s=1;i<=n;i+=2,j++)
            s+=!(p[j/8]&(1<<(j%8)));
        printf("%d\n",s);
    }
}

C++: #include <iostream>

using namespace std;

int as[1000000];

int main(){
  int n;
  for(;;){
    cin >> n;
    if(cin.eof()) break;

    for(int i=1; i<=n; i++)
      as[i]=i;

    for(int i=2; i<=n; i++){
      if(as[i]==-1)
	continue;
      else
	for(int j=2*i; j<=n; j+=i)
	  as[j]=-1;
    }

    int cnt=0;
    for(int i=2; i<=n; i++)
      if(as[i]!=-1)
	cnt++;

    cout << cnt << endl;
  }
}

C++: #include<iostream>
using namespace std;
bool isPrime(int n){
	if(n<=1||n!=2&&(n&1)==0)return false;
	for(int i=3;i*i<=n;i+=2){
		if(n%i==0)return false;
	}
	return true;
} 
int main(){
	int n,ans;
	while(cin>>n){
		ans=0;
		for(int i=2;i<=n;i++)
			if(isPrime(i))ans++;
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <string> 
#include <vector> 
using namespace std;

int main(){
	int max,n[1000],c = 0,check,a;
	cin >> max;
	for(int i = 2;max >= i;i++){
		check = 0;
		for(int iii = 1;c >= iii;iii++){
			if(i % n[iii] == 0){check = 1;break;}
		}
		for(int ii = 2;i > ii and check == 0;ii++){
			if(i % ii == 0){check = 1;break;}
		}
		if(check == 0){c++;n[c] = i;}

	}
	cout << c << endl;



}