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

C++: #include	<stdio.h>

bool isPrimeNumber(int number){
	if(number	  == 2)	return true;
	if(number % 2 == 0)	return false;
	
	for(int i = 3; i * 2 <= number ;i += 2){
		if(number % i == 0)	return false;
	}
	return true;
}

int main(int argc, char** argv){
	
	int search, counter;
	
	while((scanf("%d", &search)) != EOF){
		counter = 0;
		for(int i = 2; i <= search; i++){
			counter += isPrimeNumber(i) ? 1 : 0;		
		}
		printf("%d\n", counter);
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
ll max_n = 1e6+4; 
void solve(){
    ll p = 0;
    ll Prime[n];
    ll isPrime[n+1];
    for(int i=0 ; i<=n ; i++){
        isPrime[i] = true;
    }
    isPrime[0] = isPrime[1] = 0;
    for(int i=2 ; i<=n ; i++){
        if(isPrime[i]){
            p++;
            for(int j=2*i ; j<=n ; j+=i){
                isPrime[j] = false;
            }
        }
    }
    cout << p << endl;
}

int main(){
    while (cin >> n, cin.eof() != true){
        solve();
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int prime(int n)
{
	if(n < 2){
		return 0;
	} else if(n == 2){
		return 1;
	}
	
	if(n % 2 == 0){
		return 0;
	}
	
	for(int i = 3; i*i <= n; i+= 2){
		if(n % i == 0){
			return 0;
		}
	}
	
	return 1;
}

int main(int argc, char **argv)
{
	int n, c, i;
	int a[10] = {0, 9592, 17984, 25997, 33860, 41538, 49098, 56543, 63951, 71274};
	while(cin >> n){
		i = 0;
		c = 0;
		for(int j = 900000; j >= 100000; j -= 100000){
			if(j < n){
				i = j+1;
				c = a[j/100000];
				break;
			}
		}
		
		for(; i <= n; i++){
			if(prime(i) == 1){
				c++;
			}
		}
		
		cout << c << endl;
	}
	
	return 0;
}

C++: #include<stdio.h>
#define MAX 1000010

int main(){
	bool prime[MAX];
	prime[0]=prime[1]=0;
	for(int i=0;i<MAX;i++){
		prime[i]=1;
	}
	prime[0]=prime[1]=0;
	for(int i=2;i<MAX;i++){
		if(prime[i]==1){
			for(int j=2;i*j<MAX;j++){
				prime[i*j]=0;
			}
		}
	}
	int prime_under_num[MAX];
	prime_under_num[0]=0;
	for(int i=1;i<MAX;i++){
		prime_under_num[i]=prime_under_num[i-1]+prime[i];
	}
	
	int n;
	while((scanf("%d",&n))!=EOF){
		printf("%d",prime_under_num[n]);
	}
	
	
}

C++: #include <stdio.h>

int main(){
	int sosuu[1000000] = { 2, 3, 5 }, i,x,y=3,n;

	for (i = 3; i < 1000000; i+=2){
		for (x = 0; x < y;x++){
			if (i % sosuu[x] == 0){ break; }
			if (x+1 == y){ sosuu[y] = i, y++; }
		}
	}

	while (scanf("%d",&n)!= EOF){
		for (i = 0; i < y; i++){
			if (sosuu[i] < n + 1)break;
		}
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n;
  while(cin >> n){
    int cnt=0,res=0;
    for(int i=3; i<=n; i+=2){
      for(int j=1; j<=i; j++){
        if(i%j == 0) cnt++;
        if(cnt>2) break;
      }
      if(cnt==2) res++;
      cnt = 0;
    }
    cout << res+1 << endl;
  }
  return 0;
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int prime[1000000];
int main(){
    int n,ans=0;
    for(int i=0;i<1000000;i++)
        prime[i]=1;
    prime[1]=0;
    prime[2]=1;
    for(int i=1;i<1001;i++){
        if(prime[i]==1){
            for(int j=i+1;j<1000000;j++){
                if(j%i==0)
                    prime[j]=0;
            }
        }
    }
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        if(prime[i]==1)
        ans++;
    }
    printf("%d",ans);
    return 0;
}

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

#include <iostream>

#define MAX 999999

using namespace std;

int main()
{
    int n;
    int num_prime[MAX];
    bool prime_flag[MAX];

    for (int i = 1; i < MAX; ++i) {
        if(!prime_flag[i]){
            for (int j = 2; (i+1)*j-1 < MAX; ++j) {
                prime_flag[(i+1)*j-1]= true;
            }
        }
        num_prime[i]=num_prime[i-1]+!prime_flag[i];
    }
    while (cin>>n){
        cout<<num_prime[n-1]<<endl;
    }
    return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int main(){
    int n;
    while(cin >> n){
        bool prime[1000000] = {false};
        // falseで初期化
        prime[1] = true;
        prime[2] = false;
        int count = 0;
        
        // エラトステネスのふるい
        for(int j = 2; j * j <= n ; j++){
            if(!prime[j]){
                for (int k = 2; k*j <= n;k++){
                   prime[j*k] = true;
                }
            }
        }
        // falseだと素数
        for(int i = 1;i<=n;i++){
            if(!prime[i]) count = count +1;
        }
        cout << count << endl;
    }
    return 0;
}

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

bool IsPrime(int i){
    if(i < 2) return false;
    else if(i == 2) return true;
    else if(i % 2 == 0) return false;

    double sqrtNum = sqrt(i);
    for(int j = 3; j <= sqrtNum; j += 2){
        if(i % j == 0){
            return false;
        }
    }

    return true;
}

int main(){
    int n;
    while(cin >> n){
        int k = 0;
        for(int i = 0; i <= n; ++i){
           if(IsPrime(i) == true){
               k++;
           }else ;
        }
        cout << k << endl;
    }
}

C++: #include <iostream>
#include <cmath>
using namespace std;
bool isprime(int& num)
{
    static int c;
    for(c=2; c < sqrt(num)+1; c++)
        if(num % c ==0) return false;
    return true;
}

int main()
{
    int ans = 0;
    int buff;
    while(cin >> buff);
    {
        for(int d =2; d <= buff; d++)
            if(isprime(d)) ans++;
        cout << ans << " ";
        ans  = 0;
    }
    cout << endl;
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>
#define rep(x,to) for(x=0;x<to;x++)
#define rep2(x,from,to) for(x=from;x<to;x++)

using namespace std;


int main(void){

int num,i,cnt;


	while(cin >> num){
		cnt=1;
		for(i=3;i <= num;i+=2){
			bool swa = true;
			for(int j=3; j*j <= i;j+=2){
				if(i % j == 0){
					swa=false;
					continue;
				}

			}
			if( swa == true ){
				cnt++;
//				cout << i << " ";
			}
		}
		cout << cnt <<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		bool prime[1000000];
		for(int l=2;l<=n;l++){
			prime[l] =true;
		}
		for(int i=2;i<=n;i++){
			if(prime[i]==true){
				for(int j=i*2;j<=n;j+=i){
					prime[j]=false;
				}
			}
		}
		int count=0;
		for(int k=2;k<=n;k++){
			if(prime[k]==true) count++;
		}
		cout<<count<<endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int s[80000],m[1000000],i,j,n=0;
int main() {
	for (i=2; i<1000000 ; i++) {
		if (m[i]==0) {
			s[n++]=i;
			for (j=i; j<1000000; j+=i) m[j]=1;
		}
	}
	while(cin >> i) {
		for (j=0;s[j]<=i && j<n;j++) ;
		cout << j << endl;
	}
return 0;
}