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 <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);
}

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

using namespace std;

int main()
{
	int n;
	int head,fin;
	int temp;
	
	
//	vector<int> isPrime;
	bool isPrime[1000000];
	
	while(cin>>n)
	{
		for(int i = 0; i < n+1; i++){
//			isPrime.push_back(1);
			isPrime[i] = 1;
		}
//		cout << "Corecced!" << endl;
		isPrime[0] = isPrime[1] = 0;
		temp = 0;
		
		for(;;)
		{
			//TõXgÌæªð©Â¯é
			for(head = temp+1; head < n+1; head++){
				if(isPrime[head] == 1){
					break;
				}
			}
			//æªðÜÜÈ¢{ÍSÄ¬
			for(int i = head; i*head < n+1; i++){
				isPrime[i*head] = 0;
			}
			//TõXgÌÅãÖ
			for(fin = n; fin > 0; fin--){
				if(isPrime[fin] == 1){
					break;
				}
			}
		//	printf("head:%d    fin:%d\n",head,fin);
			
			if(fin <= head*head){
				break;
			}
			temp = head;
		}
		
		int cont = 0;
		for(int i = 0; i < n+1; i++){
			if(isPrime[i] == 1){
				cont++;
		//		cout << "+"<<i << endl;
			}
		}
		printf("%d\n",cont);
	}
}

C++: #include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
   int a,pp[100001];
   pp[0]=-1,pp[1]=-1;
   for(int i=2;i<100001;i++){
       if(pp[i]==0){
           pp[i]=1;
           for(int j=i*2;j<100001;j+=i){
               pp[j]=-1;
           }
       }
   }
   int now;
   while(cin>>now){
       int ans=0;
       for(int i=1;i<now+1;i++){
           if(pp[i]==1){
               ans++;
           }
       }
       cout<<ans<<endl;
   }
    return 0;
}

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

int main(int argc, char* argv[])
{
	int n;
	int judge(int s);
	while (scanf("%d",&n)!=EOF)
	{
	    int count=0; 
		for (int i=2;i<=n;i++)
		 {
		     if (judge(i)) count++;
		 }
		printf("%d\n",count);
	}
	return 0;
}
int judge(int s)
{
    for (int i=2;i<s;i++)
	{
	    if (s%i==0) return 0;
	}
	return true;
}

C++: #include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a; i ++)
#define loop(i,b,a) for(int i = b ; i < a; i ++)
const int MAX = (1e8);
bool p[MAX];
int num[MAX];
void isPrime(){
  rep(i,MAX)p[i] = true;
  p[0] = p[1] = false;
  num[0] = num[1] = 0;
  loop(i,2,MAX){
    num[i] = num[i-1] + p[i];
    if(p[i]){
      for(int j = i + i ; j < MAX ; j += i){
	p[j] = false;
      }
    }
  }
}

int main(void){
  isPrime();
  int n;
  while(cin>>n)cout<<num[n]<<endl;
  
  return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(int i = f; i < (int)l; ++i)

#ifdef ONLINE_JUDGE
#define DEBUG false
#else
#define DEBUG true
#endif

#define pb emplace_back
#define lb lower_bound
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second

#define ALL(c) (c).begin(),(c).end()

#define DBG0(x)    {if(DEBUG){ cout << #x << ": " << x << "\t"; }}
#define DBG(x)     {if(DEBUG){DBG0(x); cout << endl;}}
#define DBG2(x, y) {if(DEBUG){DBG0(x); DBG(y);}}
#define DBG3(x, y, z) {if(DEBUG){DBG0(x); DBG2(y, z);}}
#define DBG4(w, x, y, z) {if(DEBUG){DBG0(w); DBG3(x, y, z);}}

template <class T>
ostream& operator<<(ostream& os, vector<T> xs){ for(T x: xs) os << x << ' '; return os; }
template <class S, class T>
ostream& operator<<(ostream& os, pair<S,T> st){ os << "(" << st.first << "," << st.second <<")"; return os; }

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;

const int PN = 210000;
vint ps;
vector<bool> eratos;
void init_primes(void){
    eratos = vector<bool>(PN, false);
    ps.clear();
    for(int i = 2; i < PN; ++i){
        if(!eratos[i]){
            ps.pb(i);
            for(int j = i; j < PN; j += i)
                eratos[j] = true;
        }
    }
    return;
}
int main(void){
    init_primes();
    int n;
    while(cin >> n){
        if(n < 2){
            cout << 0 << endl;
            continue;
        }
        int l = 0, r = ps.size() - 1;
        while(r - l > 1){
            int med = (l + r) / 2;
            if(ps[med] <= n) l = med;
            else r = med;
        }
        cout << l + 1 << endl;
    }
    return 0;
}

C++: #include<stdio.h>
#include<math.h>
int main(void)
{
	long n,a,range;
	double b;
	bool flag;
	while(scanf("%d",&range)!=EOF){
	long t=0;
	for(int i=2;i<=range;i++){
		n=i;
	a=2;
	b=sqrt(n);
	flag=false;
	while(a<=b)
	{
		if(n%a==0){
			flag=true;
			break;
		}else{
			a++;
		}
	}
	if(flag==false){
			t++;
	}
	}
	printf("%d\n",t);

}

	return 0;
}