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 <iostream>
using namespace std;

int main(){
	bool prime[1000001];
	for(int i = 0; i < 1000001; i++) prime[i] = true;
	prime[0] = false;
	prime[1] = false;
	for(int i = 2; i < 1000; i++){
		for(int j = i*2; j < 1000001; j += i){
			prime[j] = false;
		}
	}

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

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

using namespace std;

int main() {
	int n;

	while (cin >> n) {
		int counter = 1;
		
		if(n < 1000){
			for (int i = 3; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		}else if(n < 10000){
			counter = 168;
			for (int i = 1001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 100000){
			counter = 1229;
			for (int i = 10001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 200000){
			counter = 9592;
			for (int i = 100001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 300000){
			counter = 17984;
			for (int i = 200001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 400000){
			counter = 25997;
			for (int i = 300001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 500000){
			counter = 33860;
			for (int i = 400001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 600000){
			counter = 41538;
			for (int i = 500001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 700000){
			counter = 49098;
			for (int i = 600001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 800000){
			counter = 56543;
			for (int i = 700001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 900000){
			counter = 63951;
			for (int i = 800001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else {
			counter = 71274;
			for (int i = 900001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		}
		cout << counter << endl;
	}

	return 0;
}

C++: #include <stdio.h>

#define MAX (1000000)

bool primeTbl[MAX];

int main() {
	
	primeTbl[0] = primeTbl[1] = true;
	for(int i=2; i<MAX; i++) {
		if(!primeTbl[i])
			for(int j=i*2; j<MAX; j+=i)
				primeTbl[j] = true;
	}
	printf("ready\n");
	int n;
	while(scanf(" %d", &n)) {
		int ans = 0;
		for(int i=2; i<=n; i++)
			if(!primeTbl[i])
				ans++;
		printf("%d %d\n", n, ans);
	}
	return 0;
}

C++: 
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
using namespace std;
typedef long long int ll;

int main(){
    int n;
    while (cin >> n) {
        vector<ll> era(n+1,0);
        for (int i=1; i<era.size(); i++) {
            era[i]=i;
        }
        for (int i=2; i<era.size(); i++) {
            if (era[i]!=0) {
                int q = i+1;
                while (q<era.size()) {
                    if (era[q]%era[i]==0) {
                        era[q]=0;
                    }
                    q++;
                }
            }
        }
        int ans=-1;
        for (int i=1; i<=n; i++) {
            if (era[i]==i) {
                ans++;
            }
        }
        cout << ans <<endl;
    }
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<deque>
#include<algorithm>
using namespace std;
//#define int long long

signed main(){
        deque<int> primes{2};

        for(int i=3;i<1000000;i+=2){
                for(unsigned int j=0;j<primes.size();j++){
                        if(primes[j]*primes[j]>i){
                                primes.push_back(i);
                                break;
                        }
                        if(i%primes[j]==0){
                                break;
                        }
                }
        }

        int a;
        while( scanf("%d", &a) != EOF ){
                cout<<distance(primes.begin(), upper_bound(primes.begin(),primes.end(),a))<<endl;
        }

        //int n;
        //scanf("%lld",&n);
        //for(int i=0;i<n;i++){}

        return 0;
}

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

int main() {
int a[1000000]{};
bool b[1000000]{};
a[1]=0;
int s=0;
for(int c=2;c<1000000;c++){
	if(!b[c]){
		s++;
		for(int d=c*2;c<1000000;d+=c)b[d]=true;
	}
	a[c]=s;
}
int k;
while(scanf("%d",&k)){
	printf("%d\n",a[k]);
}
}

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

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ELEM(array) (sizeof (array)/sizeof *(array))
#define MAX_N 1000005
#define SAFE_FREE(ptr) if( ptr != NULL ){ free(ptr); ptr = NULL; }
typedef unsigned int UINT;
#define ll long long
typedef pair<int, int> P;

bool prime[MAX_N];

void solve()
{
	memset(prime, true, sizeof(prime));
	prime[0] = prime[1] = false;
	FOR(i, 2,(int)sqrt(MAX_N))
	{
		if (prime[i] == true)
		{
			FOR(j, 2, (int)sqrt(MAX_N)){
				if (prime[i*j] == true)prime[i*j] = false;
			}
		}
	}
}

int main()
{
	int n;
	while (cin >> n)
	{

		int ans = 0;

		solve();
		REP(i, n + 1){
			if (prime[i] == true){
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
	bool flag = false;
	int num, cou, i, j;
	
	while(cin >>num){
		cou = 0;
		for(i = 3; i < num; i+= 2, flag = false){
			for(j = 3; j < sqrt(num); j += 2){
				if(i % j == 0){
					flag = true;
					break;
				}
			}
			if(flag == false) cou++;
		}
		cout <<cou + 2<<endl;
	}
	
	return 0;
}