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 := i - 1; j >= 1; j-- {
				if i%j == 0 && j != 1 {
					flag = true
					break
				}
			}
			if !flag {
				count++
			} else {
				flag = false
			}
		}
		fmt.Println(count)
	}
}

C++: #include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>

using namespace std;
typedef long long Int;
#define REP(i , x) for(int i = 0 ; i < x ; ++i)

typedef pair<int, int> P;

bool dp[1000000];

int main()
{
	int N;
	while (cin >> N){
		long ans(0);
		dp[0] = dp[1] = true;
		for (int i = 2; i <= N*N; ++i){
			if (!dp[i]){
				for (int j = 2*i; j <= N; j += i)
					dp[j] = true;
			}
		}
		for (int i = 2; i <= N; ++i){
			ans += !dp[i];
		}
		cout << ans << endl;
	}
}

C++: #include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

const int N = 100000;

int main(void)
{
    bool a[N];
    int prime[N], n, count = 0;
    rep(i,N)
    a[i] = true;
    a[0] = a[1] = false;
    for(int i=2;i*i<=N;i++)
    {
        if(a[i])
        {
            prime[i] = prime[i-1] + 1;
            for(int j=i*i;j<N;j+=i)
                a[j] = false;
        }
        else
            prime[i] = prime[i-1];
    }
    
    while(cin >> n)
    {
        rep(i,n+1)
        {
            if(a[i])
                count++;
        }
        cout << count << endl;
    }
    
    return 0;
}

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

int main(void){
int unti[1000000];
for(int n = 2;n < 10000000;n++)
{
if(unti[n] == 0)
{
for(int a = 2;(a * n) < 1000000;a++)
{
	if((a * n ) < 1000000 ) unti[a * n]++;
}
}
}
int b;
while(cin >> b )
{
int cnt = (count(unti,unti+b+1,0) - 2);
cout << cnt << endl;
	}
return 0;
}

C++: #include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
int prime[1000000];
void eratosthenes(){
    for(int i = 0; i < 1000000; i++)    prime[i] = 1;
    prime[0] = prime[1] = 0;
    for(int i = 0; i * i <= 1000000; i++)
        if(prime[i])
            for(int j = i * 2; j < 1000000; j += i)
                prime[j] = 0;
}

int main(){
    int n;
    eratosthenes();
    while(cin >> n){
        int ans = 0;
        rep(i, n + 1)if(prime[i])ans++;
        cout << ans << endl;
    }
}

C++: #include<cstdio>
#include<cstring>
using namespace std;
const int MAXN=1e7;
int is_prime[MAXN],prime[10000];
int main(void){
	memset(is_prime,-1,sizeof(is_prime));
	int index=0;
	prime[0]=prime[1]=0;
	for(int i=2;i<MAXN;i++){
		if(is_prime[i])prime[index++]=i;
		for(int j=2*i;j<MAXN;j+=i)
		is_prime[j]=0;
	}
	int n;
	while(scanf("%d",&n)!=EOF){
		for(int i=0;i<index;i++)
		if(prime[i]<=n&&prime[i+1]>n)printf("%d\n",i+1);
	}
	return 0;
}

C++: #include <stdio.h>
const int MAX_V = 1000000;
int prime[MAX_V + 1];
int sum[MAX_V + 1];
int main() {
  int i, k, v, n, max = 0;
  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(scanf("%d", &n) != EOF){
    for(i = 2;i <= n;i++){
      sum[n] += prime[i];
    }
  }
  for(i = 2;i < n;i++){
    printf("%d\n", sum[n]);
  }
  return 0;
}

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

using namespace std;
int a[1000000];

int f(int n){
    int sum=0;
   for(int i=0;i<=n;i++)a[i]=1;
   for(int i=2;i<=n;i++){
      if(a[i]==1){
         sum++;
         for(int j=2*i;j<=n;j+=i)
            a[j]=0;                        
      }        
   }
    return sum;
}

int main()
{
    int n;
    while(cin>>n){
       cout<<f(n)<<endl;              
    }
    return 0;
}

C++: #include <iostream>
#define N 1000000 

using namespace std;

bool sosu[N];

void sosuhyo()
{
	sosu[0]=true;
	sosu[1]=true;

	for(int i=2;i<N;i++){
		if(!sosu[i]){
			for(int j=2;j<(N/i);j++){
				sosu[i*j]=true;
			}
		}
	}

}


int main(){
	
	sosuhyo();

	int a,count;

	while(cin>>a && a){
		count=0;
		for(int i=0;i<=a;i++){
			if(!sosu[i])count++;
		}
		cout << count << endl;
	}

	return 0;
}

C++: #include <iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
#include<stack>
#include <string>
#include<fstream>
#include<ctime>
#include<queue>

using namespace std;
#define LL long long
#define mxn 100010
#define mxe 1000010
#define eps 1e-4
#define inf 0x7fffffff

#include<iostream>
#include<cstdio>
#define INF 999999999;
#include<iostream>
using namespace std;

#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#define MAX 1000000
using namespace std;
int amount[MAX];
int vis[MAX];
int prime[MAX];
int main(){
	memset(vis, 0, sizeof(vis));
	for(int i=0;i<MAX;i++)
        prime[i]=1;
	prime[0] = prime[1] = 0;
	for (int i = 2; i*i<= MAX; i++){
		if(prime[i])
		{
		    for(int j=i*i;j<=MAX;j+=i)
		        prime[j]=0;
		}
	}
	int sum = 0;
	for (int i = 0; i <= MAX; i++){
		if (prime[i]){
			sum++;
		}
		amount[i] = sum;
	}
	int n;
	while (cin >> n){
		cout << amount[n] << endl;
	}
	return 0;
}

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

int main()
{
    bool num[1000000]={false};
    for(int i=2;i<1000;i++){
        if(!num[i]){
            for(int j=i*i;j<1000000;j+=i){
                num[j]=true;
            }
        }
    }
    int n;
    while(cin>>n){
        int ans=0;
        for(int i=2;i<=n;i++){
            if(!num[i])
                ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

using namespace std;

const int MAX_N = 1000000;

int N;

int len;
int prime[MAX_N];				//save all prime number less than MAX_N
bool isPrime[MAX_N];

void sieve(){
	//init
	fill(isPrime, isPrime + MAX_N, true);
	isPrime[0] = isPrime[1] = false;
	
	for(int i = 2; i < MAX_N; i ++){
		if(isPrime[i]){
			prime[len ++] = i;
			for(int j = 2 * i; j < MAX_N; j += i)
				isPrime[j] = false;
		}
	}
}

void solve(){
	for(int i = len - 1; i >= 0; i --){
		if(N >= prime[i]){
			printf("%d\n", i+1);
			return;
		}
	}
	printf("0\n");
}

int main(int argc, char const *argv[]){

	sieve();
	while(scanf("%d", &N) != EOF){
		solve();
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
#include<stdio.h>
int main()
{
    int n,c=0,k=0;

	while(scanf("%d",&n))
	{


    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=i;j++)
            {
                if(i%j==0)
                    c++;
            }

                if(c==2)
                    k++;
                    c=0;
    }
    cout<<k<<endl;
	}

    return 0;
}

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

int main(){
	bool is_prime[100000];
	
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<100000;i++){
		is_prime[i]=true;
	}
	
	for(int i=2;i*i<100000;i++){
		if(is_prime[i]){
			for(int j=i*i;j<100000;j+=i){
				is_prime[j]=false;
				}
			}
		}
		
		int n_prime[100000];
		
		int cnt=0;
		for(int i=0;i<100000;i++){
			if(is_prime[i]){
				cnt++;
			}
			n_prime[i]=cnt;
		}
		
		while(true){
			int n;
			cin>>n;
			if(cin.eof())
				break;
				
			cout<<n_prime[n]<<endl;
		}
		
		return 0;
}

C++: #include<stdio.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++)
		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);
}