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 := 3; i <= num; i += 2 { //1を除く入力値以下の数字
			for j := 3; j < i; j += 2 {
				if i%j == 0 {
					flag = true
					//fmt.Println(i, "/", j)
					break
				}
			}
			if !flag {
				count++
			} else {
				flag = false
			}
		}
		fmt.Println(count + 1)
	}
}

C++: #include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

// エラストテネスの篩, o(n)程度
// n以下の素数の数を返す, prime[i]: i番目の素数, is_prime[i]: iが素数であるか
int sieve(int n, int prime[] = nullptr, bool is_prime[] = nullptr){
	bool flag0 = false, flag1 = false;
	if(prime == nullptr){
		flag0 = true; prime = new int[n];
	}
	if(is_prime == nullptr){
		flag1 = true; is_prime = new bool[n + 1];
	}

	int p = 0;
	fill(is_prime, is_prime + n + 1, true);
	is_prime[0] = is_prime[1] = false;

	for(int i = 2; i <= n; i++){
		if(is_prime[i]){
			prime[p++] = i;
			for(int j = 2*i; j <= n; j+=i) is_prime[j] = false;
		}
	}

	if(flag0) delete prime;
	if(flag1) delete is_prime;

	return p;
}


int main(void){
	int n;
	while(scanf("%d", &n)){
		if(n == EOF) break;
		cout << sieve(n) << '\n';
	}

	return 0;
}

C++: #include <iostream>

bool prime(int n);

int main(void) {
	using namespace std;
	int x;
	while (cin >> x) {
		int count = 0;
		for (int i = x; i > 1; i--) {
			if (prime(i))count++;
		}
		cout << count << endl;
	}
	return 0;
}

bool prime(int n) {
	for (int i = n - 1; i > 1; i--) {
		if (n % i == 0)return false;
	}
	return true;
}

C++: #include <iostream>
using namespace std;
int main(){
	int a[30],b,c=0,d=0;
	int flg=0;
	while(cin>>a[d]){
		for (int A=2;A<=a[d];A++){
		flg=0;
			for (int B=2;B<=A;B++){
				b=A%B;
				if (A==B){
					c++;
					break;
				}
				if (b==0) break;
			}
		}
		cout<<c<<endl;
		c=0;
		d++;
	}
	return 0;
}

C++: /*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009&lang=jp*/

#include <iostream>

using namespace std;

int main()
{
    int n;

    while (cin>>n){
        int count=0;

        while (1 < n){
            int prime_flag=1;
            for (int j = n - 1; prime_flag && 1 < j; j--) {
                if(n % j==0){
                    prime_flag=0;
                }
            }
            count+=prime_flag;
            n--;
        }
        cout<<count<<endl;
    }
    return 0;
}

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

bool check(int in){
	for (int i = 3; i<=sqrt(in); i+=2){
		if (i != 5 && i % 5 == 0)	continue;
		if (in % i == 0)
			return false;
	}
	return true;
}

int PrimeNumber(int in, int start){
	int count = 0;
	if (in > 2)	count++;
	for (int i = start; i <=in; i+=2){
		if (check(i))	count++;
	}

	return count;
}

int main(){
	int in;
	int count250000 = PrimeNumber(250000, 3);
	int count500000 = count250000 + PrimeNumber(500000, 250001);
	int count750000 = count500000 + PrimeNumber(750000, 500001);

	while (cin >> in, !cin.eof()){
		if (in <= 250000)
			cout << PrimeNumber(in, 3) << endl;
		else if (in <= 500000)
			cout << count250000 + PrimeNumber(in, 250001) << endl;
		else if (in <= 750000)
			cout << count500000 + PrimeNumber(in, 500001) << endl;
		else
			cout << count750000 + PrimeNumber(in, 750001) << endl;
	}
}

C++: #include <iostream>

using namespace std;

int sang(int n,bool *s,int *p,int &m){
	m = 0;
	for(long i = 2; i<=n;i++){
		s[i] = 2;
	}
	for(long i = 2; i<=n; i++){
		if(s[i]){
			p[m++] = i;
			for(long j = i * i; j<= n ; j += i){
				s[j] = 0;
			}
		}
	}
	return m;
}
int main(){
	int test =0;
	bool s[100005];
	int n,p[100005],m;

	while(test <999999){
		cin>>n;
		sang(n,s,p,m);
		cout<<m<<endl;
		test++;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <limits>
#include <map>
#include <string>
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[n+1];
fill((int*)table,(int*)table+sizeof(table),1);
table[0]=0;

for(int i=1;i*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 main(){
	int a[999999]={0,0,1,2},n,k=0;count=2;
	for(int i=4;i<999999;i++){
		for(int j=2;j*j<=i;j++){
			if(i%j==0)k++;
		}
		if(k==1)count++;
		a[i]=count;
		k=0;
	}
	while(cin>>n)cout<<a[n]<<endl;
	return 0;
}

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

int main() {
    const int num = 100000;
    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 <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

bool isprime (int n){

	if (n == 0 || n == 1){
		return false;
	}else if (n == 2){
		return true;
	}else if (n % 2 == 0){
		return false;
	} // end if
	
	for (int i = 3; i <= sqrt(n); i+= 2){
		if (n % i == 0){
			return false;
		} // end if
	} // end for
		
	return true;
}

int main()
{
	
//	cut here before submit 
//	freopen("testcase.prime", "r", stdin);
	int res = 0;
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;
	vector <int> prime(n+1, 0);

	int i;
	int count = 1;
	prime[2] = count;

	for (i = 3; i <= n; ++i){
		if (isprime(i)){
			++count;
		} // end if
		prime[i] = count;
	} // end for
	res = prime[n];

	cout << res << endl; 

	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
 
 
// cin >>
// cin <<
bool isPrime(int x){
    if(x==2) return true;
    if(x<2||x%2==0) return false;
    int i=3;
    while(i<=sqrt(x*1.0)){
         if (x%i==0)return false;
        i= i+2;
    }
    return true;
}
int main(){
    int in[30]={};
    int out=0;
	int max=0;
	bool flag[1000002];
    for(int i=0;i<30;i++){
		cin >>in[i];
		if(i==0){
			max=in[i];
		}else{
			if(in[i]>max){
				max=in[i];
			}
		}
	}
	for(int j=0;j<max+1;j++){
		if(isPrime(j)==true){
			flag[j]=true;
		}else{
			flag[j]=false;
		}
    }
	
    for(int i=0;i<30;i++){
		out=0;
		for(int j=0;j<in[i]+1;j++){
			 if(flag[j]==true){  
				 out++;
			 }
		}
		if(out!=0){
		 cout <<out <<endl;
		}
    }
     
    return 0;
}

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

int a[1000000];

int main()
{
  int n;
  int count;

  for (int i = 2; i < 1000000; i++){
    a[i] = 1;
  }

  for (int i = 0; i * i < 1000000; i++){
    if  (a[i] == 1){
      for (int j = 2; j * i <= 100000; j++){
        a[j * i] = 0;
      }
    }
  }

  while (cin >> n){
    count = 0;
    for (int i = 0; i < 1000000; i++){
      if (a[i] == 1){
        count++;
      }
    }
  }

  cout << count << endl;

  return (1);
}

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

int main(){
	int n;
	int count;
	int ans;

	while (cin >> n){
		ans = 0;
		for (int i = 2; i <= n; i++){
			count = 0;
			for (int j = 2; j < i; j++){
				if (i % j == 0){
					count++;
				}
			}
			if (count == 0)ans++;
		}
		cout << ans << endl;

	}


	return 0;
}