Go: package main

// https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}
		maybePrime := make([]bool, n+1)
		for i := 0; i <= n; i++ {
			maybePrime[i] = true
		}

		maybePrime[0] = false
		maybePrime[1] = false
		for i := 2; i <= int(math.Sqrt(float64(n)))+1; i++ {
			j := i * 2
			for j <= n {
				maybePrime[j] = false
				j += i
			}
		}

		nPrimes := 0
		for _, p := range maybePrime {
			if p {
				nPrimes++
			}
		}
		// fmt.Println(maybePrime)
		fmt.Println(nPrimes)
	}
}

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

int main(){
    long long n, i, j, yaku, count;
    while (scanf("%lld",&n) != EOF) {
        count=1;
        if (n==1) {
            printf("%d\n",0);
        }
        else if (n==2){
            printf("%d\n",1);
        }
        else{
            for (i=3; i<=n; i+=2) {
                yaku=0;
                for (j=3; j<=sqrt(i); j+=2) {
                    if (i%j == 0) {
                        yaku=1;
                        break;
                    }
                }
                if (yaku == 0) {
                    count++;
                }
            }
            printf("%lld\n",count);
        }
    }
    
    
    return 0;
}

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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define FORE( i, m, n ) FOR( i, m , n + 1 )
#define REP( i, n )     FOR( i, 0, n )
#define REPE( i, n )	FOR( i, 0, n + 1 )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()             
#define MP( a, b )		make_pair( (a), (b) )
#define fi				first
#define se				second

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

int prime[1000000] = {};

signed main() {
	int n;
	fill( prime, prime + 1000000, 1 );

	FOR( i, 2, 1000000 ) {
		if( prime[i] ) {
			for( int j = i * i; j < 1000000; j += i ) {
				prime[j] = 0;
			}
		}
	}

	while( cin >> n ) {
		int cnt = 0;
		FORE( i, 2, n ) {
			if( prime[i] ) cnt++;
		}
		cout << cnt << endl;
	}
}

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

int main(){
  int input;

  while(scanf("%d",&input) != EOF){
    int count = 1;

    for(int i = 3;i <= input;i += 2){
      bool isPrime = false;
      
      for(int s = 3;s <= sqrt((float)i);s += 2){
        if(i % s == 0){isPrime = true; break;}
      }
      if(!isPrime)count++;
    }
    printf("%d\n",count);
  }

  return 0;
}

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

bool is_prime(int n){
for(int i=2;i*i<=n;i++){
if(n % i == 0) return false;
}
return n!=1;
}

int main(){
int n;

while(~scanf("%d",&n)){
int* table =  new int[1000000];
memset(table,sizeof(table),1);
table[0]=0;

for(int i=1;i<=n;i++){
if(!is_prime(i)) {
for(int j=i;j<=n;j*=i){
table[j] = 0;
}
}
}
printf("%d\n",count(table,table+1000000,1));
}
}

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

int CheckNum(int input){
	int count = 0;

	for(int i = 2; i < input; ++i){
		for(int j = 2; j < i + 1; ++j){
			if( i % j == 0){
				if(!(i == j)) break;
				++count;
			}
		}
	}
	return count;
}

int main () {
	int input;

	while(cin >> input)
	cout << CheckNum(input) << '\n';

	return 0;
}

C++: #include<stdio.h>



int main(){
	int n,i,j;
	bool c[1000000];
	int count;


	while(scanf("%d",&n)!=EOF){
		count=0;
		c[0]=c[1]=0;
		for(i=2;i<=n;i++){
			c[i]=1;
		}
		
		for(i=0;i*i<=n;i++){
			if(c[i]==1){
				for(j=i+1;j<=n;j++){
					if(j%i==0)c[j]=0;
				}
			}
		}


		for(i=0;i<=n;i++){
			if(c[i]==1){
				count++;
			}
		}

		printf("%d",count);


	}





	return 0;
}

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

int main(){
int unti[100002] = {0};
fill(unti,unti + 100001,0);
for(int n = 2;n < 100001;n++)
{
if(unti[n] == 0)
{
for(int a = 2;(a * n) < 100001;a++)
{
	if((a * n  ) < 100001 ) unti[a * n]++;
}
}
}
int b;
while(cin >> b )
{
	if (b == 0){
		cout << 0 << endl;
	}else{
int cnt = (count(unti,unti+b+1,0) - 2);
cout << cnt << endl;
	}
}

}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void) {
	long long int n;
	while (cin >> n) {
		int m = 0;
		long long int prime[200000];
		bool is_prime[200000];
		for (int i = 0; i <= n; i++) {
			is_prime[i] = true;
		}
		is_prime[0] = is_prime[1] = false;
		for (int i = 2; i <= n; i++) {
			if (is_prime[i]) {
				m++;
				for (int j = i * 2; j <= n; j += i) {
					is_prime[j] = false;
				}
			}
		}
		cout << m << endl;
	}
	return 0;
}

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

int main(){
int n;
vector<int> a;
  while(cin >> n){
  a.push_back(n);
  }
for(int i=0;i<a.size();i++){
  int k = 0;
  for(int j=2;j<a[i];j++){
    if(a[i]%j == 0 ) k++;
	}
  cout << k ;
 }
}

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

int main()
{
	long int n,m;
	while(cin>>n){
		long int i;
		int number[100000]={0};
		int ans=0;

		for(i=0;i<n;i++){
			if(number[i]==0){
				ans++;
				for(m=i;m<n;m+=i){
					number[i]=1;
				}
			}
		}
		cout<<ans<<endl;
	}
}

C++: #include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxn=999999+10;
int n,cnt,t;
int pre[maxn],prime[maxn];
int get(int x){
	int l=0,r=t-1,mid;
	while(l<=r){
		mid=(l+r)>>1;
		if(prime[mid]>=x)
			r=mid+1;
		else
			l=mid+1;
	}
	return r;
}
int main(){
	memset(pre,0,sizeof(pre));
	memset(prime,0,sizeof(prime));
	t=1;
	for(int i=2;i<maxn;i++){
		if(!pre[i])
			prime[t++]=i;
		for(int j=1;j<=t&&i*prime[j]<maxn;j++){
			pre[prime[j]*i]=prime[j];
			if(i%prime[j]==0)
				break;
		}
	}
	while(cin>>n){
		int ans=0;
		while(prime[ans]<=n)
			ans++;
		cout<<ans-1<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
bool IsPrime(int n)
{
	int s = floor(sqrt(n)+0.5);
	for(int i = 2;i<=s;i++)
		if(n%i==0)return false;
	return true;
}
const int maxn = 1000000;
bool ar[maxn];
int dp[maxn];
int main()
{
	for(int i = 2;i<=maxn;i++)
		if(IsPrime(i))
		{
			ar[i] = true;
			dp[i] = dp[i-1]+1;
		}
		else dp[i] = dp[i-1];
	int n;
	while(cin >> n)
		cout << dp[n] <<endl;
	return 0;
}

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


int main() {

	int judge[1000000];
	for(int k=0;k<1000000;k++)judge[k]=1;
	int n,sum;
	
	while(cin>>n){
		if(n==0||n==1){
			sum = 0;
		}else{
			sum = 1;
			for(int i=3;i<n+1;i+=2){
				if (judge[i]==1){
					sum++;
					for(int j=2;j<=n/i;j++)
						judge[i*j] = 0;
				}	
			}
		}
		
		cout << sum <<endl;
	}

	return 0;
}

C++: #include&<iostream>
#include&<vector>
using namespace std;
int main(){
    int n,k,sum,check;
    int t=1;
    vector<int> prime;
    prime.push_back(0);
    prime.push_back(0);
    for(int i=2;i<1000000;i++){
        prime.push_back(1);
    }
    while(t<1000000){
        for(int j=t+1;j<=1000000;j++){
            if(prime[j]==1){
                t=j;
                for(k=2*j;k<=1000000;k+=j){
                    prime[k]=0;
                }
                break;
            }
            else if(j==1000000){
                t=1000000;
            }
        }
    }
    while(cin>>n){
        sum=0;
        for(check=1;check<=n;check++){
            if(prime[check]==1){
                sum+=1;
            }
        }
        cout << sum << endl;
    }
    return 0;
}

C++: j,a['   '],s;main(i){for(;++i<1e6||~scanf(s="%d\n",&j)&&printf(s,a[j]);)for(a[i]=s+=!a[j=i];j<1e6;a[j+=i]=1);}