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 <cstdio>
#include <vector>

const int MAX_N = 999999;
std::vector<bool> primes(MAX_N, true);

void sieve() {
  primes[0] = false;
  primes[1] = false;
  for (int i = 2; i < primes.size(); ++i) {
    if (!primes[i]) { continue; }
    for (int j = 2, m = i * j; m < primes.size(); m = i * ++j) {
      primes[m] = false;
    }
  }
}

int main() {
  sieve();

  int n;
  while (true) {
    if (scanf("%d", &n) != 1) { break; }
    int count = 0;
    for (int i = 0; i <= n; ++i) { if (primes[i]) { ++count; } }
    printf("%d\n", count);
  }

  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;
	while(cin >> max){
		c = 0;
		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;
	}



}

C++: #include<stdio.h>



int main(){
	int n,i,j;
	bool c[100000];
	int data[100000];
	int count;
	int premaxin=1;


	for(i=0;i<100000;i++){
		c[i]=1;
		data[i]=0;
	}
	c[0]=c[1]=0;

	while(scanf("%d",&n)!=EOF){

		if(premaxin<n){
			for(i=0;i<=n;i++){
				if(c[i]==1){
					if(premaxin>i){
						j=premaxin;
					}else{
						j=i+1;
					}
					for(;j<=n;j++){
						if(j%i==0){
							c[j]=0;
						}
					}
				}
			}

			count=data[premaxin];
			for(i=premaxin+1;i<=n;i++){

				if(c[i]==1){
					count++;
				}
				data[i]=count;
			}
		}

		printf("%d",data[n]);
	}
	return 0;
}

C++: #include<stdio.h>
#include<math.h>
main(){int i,j,n,p[1000000];scanf("%d",&n);for(i=2;i<=n;i++)p[i]=1;for(i=2;i<=n;i++)if(p[i])for(j=2;i*j<=n;j++)p[i*j]=0;j=0;for(i=2;i<=n;i++)j+=p[i];printf("%d\n",j);}

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

bool CheckPrimeNumber(int number) {
	int max = (int)std::sqrt(number);
	for (int i=2; i<=max; i++)
		if (number % i == 0)
			return false;
	return true;
}

int main() {
	int n, cnt;
	while (std::cin >> n) {
		cnt = 0;
		for (int i=2; i<=n; i++)
			if (CheckPrimeNumber(i))
				cnt++;
		std::cout << cnt << std::endl;
	}
	return 0;
}

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

int main(){
 int i,j,n,count,flg;
 scanf("%d",&n);
 for(i=2,count=0;i<=n;i++){
  for(j=2,flg=1;j<=sqrt(i);j++)
   if(i%j==0){ printf("%d\n",i); flg=0; break; }
  count+=flg;
 }
 printf("%d\n",count);
 return 0;
}

C++: #include <stdio.h>

int main() {
    int i, k, v,an1,an2,suu;
    int MAX_V = 10000;
    int prime[MAX_V+1];
    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;   
            } 
        }
    }
   while(1){
        scanf("%d",&suu);
        if(suu != 0){
            for(k=2;k<=suu;k++){
            	if(prime[k-2]==1 && prime[k]==1){
        	    	an1=k-2;
        	    	an2=k;
            	}
            }
            printf("%d %d\n",an1,an2);
        }
        else{
    	    break;
        }
    }
    return 0; 
}

C++: #include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int main(){
    
    ll n;
    while(cin>>n){
        ll ans=0;
        for(int i=3;i<=n;i+=2){
            int flag=0;
        for(int j=3;j<=sqrt(i);j+=2){
            if(i%j==0){
                flag=1;
                break;
            }
        }
            if(flag==0){
                ans++;
            }
    }
        cout<<ans+1<<endl;
        }
    
    
    
    
    
    
    return 0;
}

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

bool isPrime(int n)
{
    if(n<=1)
        return false;
    if(n==2)return true;
    if(n%2==0)return false;
    int m=sqrt(n);
    for(int i = 3; i<=m; i+=2)
        if(n%i == 0)
            return false;

    return true;
}

int main()
{
    int num,i,count;

    while(scanf("%d",&num)==1){
        count=0;
       for(i=1;i<=num;i++){

        if(isPrime(i))
            count++;
        }
    printf("%d\n",count);
    }
    return 0;
}

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

int main()
{
	int n = 0, x = 0;
	int countdata[1000];
	while (cin >> n) {
		if (n / 1000000 > 0) {
			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;
	}
	return EXIT_SUCCESS;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;



int main(){
	for(int n; cin >> n; ) {
		vi p(n + 1, 1);
		p[0] = p[1] = 0;
		int ans = 0;
		rep(i, n + 1) if (p[i]) {
			ans++;
			for (int j = i + i; j <= n; j += i) p[j] = 0;
		}
		cout << ans<< endl;
	}
	return 0;
}

C++: /*
 0…未確定
 1…素数
 2…素数でない
*/
#include <iostream>

using namespace std;

int main(){
    int num[1000000]={0}, b, a, n, c;
    for(int i=2;i<=1000;i++){
        if(num[i]==0){
            num[i]=1;
            b=1;
            while((a=(++b*i))<1000000) num[a]=2;
        }
    }

    while(cin >> n){
        c=0;
        for(int i=2;i<=n;i++) {
            if(num[i]==1||num[i]==0) c++;
        }
        cout << c << endl;
    }
    return 0;
}

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

int main(){
	bool b[1000000] = {};
	for(int i = 2; i < 1000000; i++){
		b[i] = true;
	}
	for(int i = 2; i < 1000; i++){
		if(b[i]){
			for(int j = i * i; j < 1000000; j += i){
				b[j] = false;
			}
		}
	}

	int n;
	while(cin >> n){
		int count = 0;
		for(int i = 0; i <= n; i++){
			if(b[i]){
				count ++;
			}
		}
		cout << count << endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
int main(void) {
    int i,j,n,ans=0,prime[1000000];
    prime[0]=0;prime[1]=0;
    for(i=2;i<1000000;i++){prime[i]=1;}
    for(i=2;i<1000000;i++){
        if(prime[i]==1){
            ans++;
            if(i<1000)for(j=i*i;j<1000000;j+=i)prime[j]=0;
        }
        prime[i]=ans;
    }
    while(scanf("%d",&n)!=EOF){printf("%d\n",prime[n]);}
    return 0;
}