Go: package main
import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	//"math"
)

var sc = bufio.NewScanner(os.Stdin)

func main(){
	for sc.Scan(){
		n := nextInt()
		fmt.Println(calc(n))
	}
}

func calc(n int)int{
	// エラトステネスで数え上げる
	// 最初から999999まで用意しておいて入力のたびO(1)で出すのとどっちが速いのかはわからん
	eratos := make([]bool, n+1)
	c := 0
	for i:=2; i<len(eratos); i++{
		if eratos[i] == false{
			c++
			for j:=i*i; j<len(eratos); j+=i{
				eratos[j]=true
			}
		}
	}
	return c
}

func next()string{
	return sc.Text()
}

func nextInt()int{
	a, _ := strconv.Atoi(next())
	return a
}

C++: #include<bits/stdc++.h>
#define sd(x) scanf("%d",&x)
#define ss(x) scanf("%s",x)
#define sc(x) scanf("%c",&x)
#define sf(x) scanf("%f",&x)
#define slf(x) scanf("%lf",&x)
#define slld(x) scanf("%lld",&x)
#define me(x,b) memset(x,b,sizeof(x))
#define pd(d) printf("%d\n",d);
#define plld(d) printf("%lld\n",d);
#define eps 1.0E-8
// #define Reast1nPeace

typedef long long ll;

using namespace std;

const int INF = 0x3f3f3f3f;

bool p[1000010];

void P(){
	memset(p,1,sizeof(p));
	p[0] = p[1] = 0;
	for(int i = 2 ; i*i<=1000000 ; i++){
		if(p[i]){
			for(int j = i+i ; j<=1000000 ; j+=i){
				p[j] = 0;
			}
		}
	}
}

int main(){
#ifdef Reast1nPeace
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	P();
	
	int n;	
	while(cin>>n){
		int ans = 0;
		for(int i = 1 ; i<=n ; i++){
			if(p[i]){
				ans++;
			}
		}
		cout<<ans<<endl;	
	}
	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]=v[1]=false;
    for(int i = 2;i<MAX;i++){
      if(v[i]){
        for(long long int j=(long long int)i*(long long int)i;j<MAX;j+=i){
          cout <<i<<" "<<j<<endl;
         v[j]=false;
       }
      }
    }
    for(int i = 2;i<MAX;i++)v[i]+=v[i-1];
    while(true){
      int a;
      cin >> a;
      if(cin.eof())break;;
      cout << v[a] << endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int n,count = 0;
	int result = 0;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		count = 0;

		for (int j = 1; j <= i; j++)
		{
			if (i%j == 0)
			{
				count++;
			}
		}
		if (count == 2)
		{
			result++;
		}
	}
	cout << result << endl;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main( void )
{
	int n;
	cin >> n;
	
	vector <bool> p(n, true);
	p[2] = true;
	for ( int i = 3; i * i < n; i += 2 )
	{
		if ( p[i] )
		{
			for ( int j = i+i; j < n; j += i )
			{
				p[j] = false;
			}
		}
	}

	int kotae = 1;
	for ( int i = 3; i < n; i += 2 )
	{
		if ( p[i] )
			kotae++;
	}

	cout << kotae << endl;

	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
#include <ctype.h>
#include <cstdlib>
#include <string.h>
#include <cmath>
#include <cstdio>





using namespace std;

bool isPrime(int num);

int main()
{
	int input, count = 0;

	while (cin >> input)
	{
		count = 0;

		for (int i = 2; i <= input; i++)
		{
			if (isPrime(i))
			
				count++;
	
		}
		cout << count << endl;
	}

	
}

bool isPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	

	double sqrtNum = sqrt(num);

	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
			return false;
	}

	return true;
}

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


int sum[1000010];
void init(){
    for(int i = 2 ; i <= 1000000 ; i++){
        sum[i] = sum[i-1] + 1;
        for(int j = 2 ; j < i ; j++){
            if( i % j == 0 ){
                sum[i]--;
                break;
            }
        }
    }
}
int main() {
    init();
    int n;
    while( cin >> n && n ){
        cout << sum[n] << endl;
    }
}

C++: #include <stdio.h>

int isPrime(int x);

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

int isPrime(int x){
    for (int i=2; i*i<=x; i++){
        if (x%i == 0) return 0; 
    }
    return 1;
}

C++: #include <stdio.h>
int main(){
	int i,j,n,num=0;
	bool prime[100000];
	bool flag=true;
	for(i=0;i<99999;i++) prime[i]=true;
	while(scanf("%d",&n)!=EOF){
		num=0;
		for(i=2;i<n+1;i++){
				for(j=i*2;j<n+1;j=j+i) prime[j]=false;
		}
		for(i=2;i<n+1;i++){
			if(prime[i]==true) num++;
		}
		printf("%d\n",num);
	}
}

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

using namespace std;
const int MAX = 1000000;
int data[MAX];
vector<int> V;

void make(){
  fill(data,data+MAX,1);
  
  for(int i = 2; i*i < 1000000; i++){
    if(data[i] == 1){
      for(int j = i*2; j < 1000000; j+=i) data[j] = 0;
    }
  }
  V.push_back(2);
  for(int i = 3; i < MAX; i+=2)
    if(data[i]) V.push_back(i);
}

int main(){
  make();
  int in;
  while(cin >> in){ 
    cout << upper_bound(V.begin(),V.end(),in)-V.begin() << endl;
  }
  return 0;
}

C++: #include<iostream>
int main() {

  int n,i,j,c;
  int list[999999];
  for(i=0;i<999999;i++)list[i]=i+2;
  for(j=2;j*j<999999+3;j++)
    if(list[j-2]!=0)
      for(i=1;j-2+list[j-2]*i<999999+1;i++)
	list[j-2+list[j-2]*i]=0;
  while(std::cin>>n){
    c=0;
    for(i=0; i<n-1; i++)
      if(list[i]!=0)c++;

    std::cout<<c<<"\n";
  }
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

vector<bool> isPrime;

void sieve(int MAX) {
  if (MAX + 1 > isPrime.size()) isPrime.resize(MAX + 1, true);
  isPrime[0] = false;
  isPrime[1] = false;
  for (int i = 2; i * i <= MAX; ++i) {
    if (isPrime[i]) {
      for (int j = 2; i * j <= MAX; ++j) isPrime[i*j] = false;
    }
  }
}

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  sieve(10000010);

  vector<int> cum(10000015);
  for (int i = 1; i <= 10000010; ++i) {
    cum[i] = cum[i-1];
    if (isPrime[i]) ++cum[i];
  }

  i64 n;
  while (cin >> n) {
    cout << cum[n] << "\n";
  }

  return 0;
}

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

int prime(int data){
	int i;
	for(i=3;i<=sqrt(data);i+=2){
		if(data%i==0){
			return 0;
		}
	}
	return 1;
}

int main(void){
	int list[1000000]={0,1};
	int i,data,cnt;
	for(i = 3;i <= 999999;i++){
		if(i%2==0){
			list[i-1]=0;
		}else{
			list[i-1] = prime(i);
		}
	}
	while(std::cin >> data){
		cnt = 0;
		for(i=0;i<data;i++){
			if(list[i] == 1){
				cnt++;
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

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 <stdio.h>

int main(){
	long sosuu[200000] = { 2 }, i, x, y = 1, z = 0;


	while(scanf("%d", &z)!=EOF){//入力した数以下の素数を表示

		for (i = 3; i < z + 1; i += 2){
			for (x = 0; x < y; x++){
				if (i % sosuu[x] == 0){ break; }
				if (x + 1 == y){ sosuu[y] = i, y++; }
			}
		}
		if (z < 2){ y = 0; }
	printf("%d\n", y);//最後に素数の合計数を表示

	for (i = 1; i < y; i++){
		sosuu[i] = 0;
	}y = 1; z = 0;
	}

	return 0;
}