Go: package main

import (
  "fmt"
  "math"
)

func main() {
  const N = 1000000
  var temp [N+1]bool
  for i:=0; i<N+1; i++ {
    temp[i] = true
  }
  temp[0] = false
  temp[1] = false
  for i:=2; i<int(math.Ceil(math.Sqrt(float64(N+1)))); i++{
    if (temp[i]){
      for j:=i*2; j<N+1; j+=i{
        temp[j] =false
      }
    }
  }
  var a int
  var b int
  for _, err := fmt.Scan(&a); err == nil; _, err = fmt.Scan(&a) {
    b = 0
    for i:=0; i<=a; i++{
      if temp[i] {
        b++
      }
    }
    fmt.Println(b)
  }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

// stl;
const int MAX = 1999999;
vector<bool> count()
{
	vector<bool> res(MAX + 1, false);
	
	for(int i = 2; i <= MAX; i++)
	{
		res[i] = true;
		for(int j = 2; j * j <= i; j++)
		{
			if(i % j == 0)
			{
				res[i] = false;
				break;
			}
		}
	}
	
	return res;
}

int main()
{
	vector<bool> table(count());
	
	int n;
	while(cin >> n)
	{
		cout << count(table.begin(), table.begin() + n + 1, true) << endl;
	}
}

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

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

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

C++: #include <iostream>

using namespace std;

int main()
{
	int n;

	while (cin >> n){
		int pn = 0;
		for (int i = 2; i <= n; i++){
			bool flag = true;
			for (int j = 2; j <= n; j++){
				if (i % j == 0 && i != j){
					flag = false;
					break;
				}
			}
			if (flag) pn++;
		}
		cout << pn << endl;
	}

	return 0;
}

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

int main() {
    const int num = 1000000;
    vector<int> pnums(num);
    vector<bool> np(num);
    np[0] = np[1] = true;

    for(int i = 2; i < num; ++i) {
        pnums[i] = pnums[i - 1] + !np[i];

        if(!np[i]) {
            for(int j = i; j < num; j += i) {
                np[j] = true;
            }
        }
    }

    for(int n; cin >> n;)
        cout << pnums[n] << endl;

    return 0;
}

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

typedef unsigned int Int;

Int sqrt_prm(const Int& target, Int x = 0) {
	while (x*x < target) {
		x++;
	}
	return x;
}

int main() {
	while (not std::cin.eof()) {
		Int target;
		std::cin >> target;

		std::vector<Int> primes = {};
		Int sqrt = 1;
		for (Int n = 3; n <= target; n+=2) {
			bool flag = true;

			sqrt = sqrt_prm(n, sqrt);
			for (auto&& p = primes.begin(); not(*p > sqrt or p == primes.end()); p++) {
				if (n % *p == 0) {
					flag = false;
					break;
				}
			}

			if (flag) {
				primes.push_back(n);
			}
		}

		std::cout << primes.size() + (target >= 2 ? 1 : 0) << std::endl;
	}
}

C++: 	public static void main(String[] args) {
		int n = 35;
		int a,b,c,d;
		int cnt = 0;
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				if(i+j > n) break;
				for (int k = 0; k < 10; k++) {
					if(i+ j + k > n) break;
					for (int l = 0; l < 10; l++) {
						if(i+j+k+l > n) break;
						if(i+j+k+l == n) {
							cnt++;
							System.out.println(i + " " + j + " " + k + " " + l);
						}
					}
				}
			}
		}
	}

C++: #include <iostream>
#include <vector>
#include <limits.h>
using namespace std;
int main()
{
	int k, n, s, t, i = 0, j, maxV = INT_MIN, A[30] = {};
	while (cin >> k) {
		if (0 == k)break;
		A[i++] = k;
		if (maxV < k)
			maxV = k;
	}
	s = maxV + 1;
	vector<long> vP(s, 0);
	int c = 0;
	for (k = 2; k < s; ++k){
		if (vP[k] == 0)
			vP[k] = ++c;
		else if (vP[k] == -1)
			vP[k] = c;
		t = (s - 1) / k;
		for (j = 2; j <= t; ++j)
			vP[j * k] = -1;
	}
	for (j = 0; j < i; ++j)
		cout << vP[A[j]] << "\n";
	return 0;
}

C++: #include<cstdio>

long prim[1000100];
long prima[1000100];
    
int main() {
    long n, i, x = 0;
    for (i = 2; i <= 1000000; i++) {
        prim[i] = i;
    }
    for (i = 2; i <= 1000000; i++) {
        if (prim[i] != 0) {
                  prima[x] = prim[i];
                  x+= 1;
                  int j = i;
                  while ( j <= 1000000) {
                        prim[j] = 0;
                        j+= i;
                  }
        }
    }
    while (scanf("%ld", &n) != EOF) {
          long a = 0;
          while ( prima[a] <= n) {
                a++;
          }
          printf("%ld\n", a);
    }
    return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include <sstream>
using namespace std;
int main(void){
    int n,ans,i;
    while(cin >> n){
        ans = 0;
        if(n < 2){
            cout << 0;
            continue;
        }else if(n == 2){
            cout << 1;
            continue;
        }else{
            ans++;
        }
        for(i = 3; i <= n; i += 2){
            double sqrti = sqrt(i);
            if(ceil(sqrti) == floor(sqrti)){
                continue;
            }
            ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

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

bool isPrime(int num) {
    if(num < 2) return(false);
    for(int r = 2; r * r <= num; r++) {
        if(num % r == 0) return(false);
    }
    return(true);
}

int main(void) {
    int num;
   
    while(cin >> num) {
        int prime[num + 1];
        memset(prime, -1, sizeof(prime));
        prime[0] = prime[1] = 0;
        for(int r = 2; r <= num; r++) {
            //cout << "Eratosthenes" << endl;
            if(prime[r] != -1) continue;
            if(isPrime(r)) {
                prime[r] = 1;
                for(int c = r * 2; c <= num; c += r) prime[c] = 0;
            } else prime[r] = 0;
        }
        int sum = 0;
        for(int r = 0; r < num + 1; r++) {
            sum += prime[r];
        }
        cout << sum << endl;
    }
}

C++: #include <iostream>

using namespace std;

int main()

{

              int get_num,min_remainder=1,remainder,index=2;

              cout << "整数を入力してください" << endl;

              cin >> get_num;

              if(get_num == 1)

              {

                            min_remainder=0;

              }

              if(get_num > 2 && get_num%2 == 0)

              {

                            min_remainder=0;

              }

              while(index*index <= get_num)

              {

                  remainder = get_num%index;

                  if(remainder < min_remainder)

                  {

                      min_remainder=0;

                  }

                  index++;

              }

              if(min_remainder !=0)

              {

                  cout << get_num << "は素数です" << endl;

              }

              else

              {

            cout << get_num << "は素数ではありません" << endl;

             }
return 0;

}