Go: package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = i
        }

        Soe()

        for i := 0; i < MAX; i++ {
                primes[i] %= 2
        }
        primes[1] = 0
        primes[2] = 1
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := 2; j < MAX/i; j++ {
                                if i * j < MAX {
                                        primes[i*j] = 0
                                }
                        }
                }
        }
}

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<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int ma=1e7;
  vector<bool>sosu(ma,1);
  sosu[0]=sosu[1]=0;
  for(int i=4;i<ma;i+=2)sosu[i]=0;
  for(int i=3;i<ma;i+=2)
    for(int j=i*3;j<ma;j+=i*2)sosu[j]=0;
  int in;
  while(cin>>in){
    int co=0;
    loop(i,2,in+1)if(sosu[i])co++;
    cout<<co<<endl;
  }
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n,prime[1000000]={0};
  int count=0;
  while(cin>>n/*入力（EOF）*/){
    for(int i=2/*0と１は素数ではないため２から始める。*/;i<=sqrt(n)/*ルートn*/;i++){
      for(int j=i*2/*i*2は必ず素数ではない*/;j<=n;j+=i/*j<=nまでi*aをする。*/){
	prime[j]=1;/*jは素数ではない。*/
      }
    }
    for(int i=2;i<=n;i++){
      if(prime[i]==0){/*もし素数だったら*/
	count++;
      }
    }
  cout<<count<<endl;
  count=0;
  }
  return 0;
}

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

int main()
{
	int n;
	int i,j,count,flag,temp;
	while(cin>>n)
	{
		count = 0;
		for(i = 3;i <= n;i++)
		{
			flag = 0;
			temp = sqrt(i);
			for(j = 2;j<=temp;j++)
			{
				if(i%j==0)
				{
					flag = 1;
					break;
				}
			}
			if(flag!=1)
				count++;
		}
		cout<<count+1<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>

using namespace std;

int main(void){
	
	int i, j, n, count = 0;
	bool arr[999999] = {false};

	while (cin >> n) {

		for (i = 2; i <= n; i++) {
			arr[i] = true;
		}

		for (i = 2; i <= sqrt(n); i++) {
			if(arr[i])
				for (j = 0; i*(j + 2) <= n; j++) {
					arr[i*(j + 2)] = false;
				}
		}

		for (i = 2; i <= n; i++) {
			if (arr[i] == true)
				count++;
		}

		cout << count << endl;
		count = 0;

	}

	return 0;
}

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


int main() {

//変数の宣言

	int i,n,j;
	
	while(cin>>n){
		vector<int> prime;
		prime.push_back(2);
		
		for(i=3;i<n+1;i++){
			for(j=0;j<prime.size();j++){
				if (i%prime[j]==0) break;
				if (j==prime.size()-1) {
					prime.push_back(i);
				}
			}
		}
		
		/*
		for(i=0;i<prime.size();i++){
			cout << prime[i] <<endl;
		}
		*/
		cout << prime.size() <<endl;
	}

	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
#define MAX 1000000
bool sosu[MAX]={false};
int main(){
  for(int i=3;i<MAX;i+=2){
    if(sosu[i])continue;
    for(int j=i*3;j<MAX;j+=i*2)
      sosu[j]=true;
  }
  for(int i=4;i<MAX;i+=2)
    sosu[i]=true;
  int in;
  while(cin>>in){
    int co=0;
    loop(i,2,in+1)if(!sosu[i])co++;
    cout<<co<<endl;
  }


}

C++: #include <bits/stdc++.h>
using namespace std;

typedef long long ll;


vector<ll> is_prime(999999+1,true);

void init_prime() {
    is_prime[0] = is_prime[1] = false;
    for(int i=2; i<=999999; i++) {
	if(is_prime[i]) {
	    for(int j=i*2; j<=999999; j+=i)
		is_prime[j] = false;
	}
    }
}

int table[1000000] = {0};

int main() {

    init_prime();

    for(int i=1; i<1000000; i++) {
	if(is_prime[i]) 
	    table[i] = table[i-1]+1;
	else
	    table[i] = table[i-1];

    }
    
    
    int a;
    
    while(cin >> a) {
	cout << table[a] << endl;
	
    }


    return 0;
}

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

using namespace std;

int main()
{
	int n;
	
	while (scanf("%d", &n) != EOF){
		vector<int> prime;
		
		if (n >= 2){
			prime.push_back(2);
		}
		for (int i = 3; i <= n; i++){
			int j;
			for (j = 0; j < prime.size(); j++){
				if (i % prime[j] == 0){
					break;
				}
			}
			if (j == prime.size()){
				prime.push_back(i);
			}
		}
		printf("%d\n", prime.size());
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

bool a[1000000];

int main()
{
    memset(a, true, sizeof(a));

    for (int i = 2; i < 1000000; i += 1 + (i & 1)) {
        if (!a[i]) continue;
        for (int j = i*2; j < 1000000; j += i) a[j] = false;
    }

    int n;
    while (~scanf("%d", &n)) {
        int cnt = 0;
        for (int i = 2; i <= n; ++i) cnt += a[i];
        printf("%d\n", cnt);
    }
}

C++: #include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define MAXN 999999
using namespace std;
bool is_prime[MAXN];
int prime[MAXN];
int main()
{
    int p=0;
    for(int i=0;i<=MAXN;i++) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<=MAXN;i++)
        if(is_prime[i])
    {
        prime[p++]=i;
        for(int j=2*i;j<=MAXN;j+=i) is_prime[j]=false;
    }
    int n,x;
    while(scanf("%d",&n)!=EOF)
    {
      x=lower_bound(prime,prime+p,n)-prime;
      if(prime[x]==n) printf("%d\n",x+1); else printf("%d\n",x);
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}
int lcm(int a,int b){if(a==0){return b;} return a/gcd(a,b)*b;}
long long MOD; template<class T> void mod(T &n){MOD=n;}
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

bool isprime(int n){
  if(n==2||n==3) return true;
  for(int i=2; i*i<=n; i++) if(n%i==0) return false;
  return true;
}

signed main(){
  int n;
  while(cin>>n&&n){
    if(n==1){cout<<0<<en; RE;}
    int ans=0;
    for(int i=2; i<=n; i++){
      if(isprime(i)) ans++;
    }
    cout<<ans<<en;
  }
}