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 <iostream>
using namespace std;
int main(){
    int n,i,j;
    int ans;
    cin >> n;
    //while(cin >> n){ 
        ans=0;
        for(i=2;i<=n;i++){
            for(j=2;j<=i;j++)
                    if(i%j==0){
                        
                        //nの因数iが素数かどうかを判定する
                        //割り切れたら素数じゃないのでループ抜ける
                        
                        break;

            }
                    //jが最終まで行けばiが素数なのでans++
                    if(j==i)ans++;
        }
        cout << ans << endl;
    //}
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#define maxn 1000000
using namespace std;
int prime[maxn],number[maxn];
void getprime()
{
    int m=sqrt(maxn+0.5);
    for(int i=2;i<=m;i++)
    {
        if(!prime[i])
        {
            for(int j=i+i;j<maxn;j+=i)
            {
                prime[j]=1;
            }
        }
    }
    int sum = 0;
    for(int i=2;i<maxn;i++)
    {
        if(!prime[i])
        {
            sum++;
        }
        number[i]=sum;
    }
}
int main ()
{
    int n;
    getprime();
    while(scanf("%d",&n)!=EOF)
    {
        printf("%d\n",number[n]);
    }
}
/**
--------------------- 
???zhaiqiming2010 
???CSDN 
???https://blog.csdn.net/zhaiqiming2010/article/details/62281598 
?????????????????????????
**/

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

int main() {

  int x;
  int count_cin = 0;
  while(true){
    cin >> x ;
    count_cin++;

    if(count_cin == 30) break;


    bool array[max_n];

    for(int i = 0; i < max_n; i++) {
      array[i] = true;
    }

    array[0] = false;
    array[1] = false;
    for(int i = 2; i < max_n; i++) {
      for(int j = 2; j < max_n; j++) {
        if(i * j > max_n) break;
        array[i * j] = false;
      }
    }

    int count_sosu = 0;

    for(int i = 0; i < x; i++) {
      if(array[i] == true) count_sosu++;
    }

    cout << count_sosu << endl;
  }

}

C++: /*
 * fudq.cpp
 *
 *  Created on: 2015-10-24
 *      Author: bjfudq
 */
#include <functional>
#include <algorithm>
#include <iostream>
//#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,102400000")


#define MEM(a) (memset((a),0,sizeof(a)))
#define LEN(a) (int)strlen((a))
#define fr(a) for(int i=0;i<(a);i++)
#define sf(a) scanf("%d",&(a))
#define sf64(a) scanf("%I64d",&(a))
#define sff(a) scanf("%lf",&(a))
#define sfs(a) scanf("%s",(a))
#define sf2(a,b) scanf("%d%d",&(a),&(b))
#define sf3(a,b,c) scanf("%d%d%d",&(a),&(b),&(c))
#define sf2s(a,b) scanf("%s%s",(a),(b))
#define sf2f(a,b) scanf("%lf%lf",&(a),&(b))
#define sf3f(a,b,c) scanf("%lf%lf%lf",&(a),&(b),&(c))
#define sf264(a,b) scanf("%I64d%I64d",&(a),&(b))
#define sf364(a,b,c) scanf("%I64d%I64d%I64d",&(a),&(b),&(c))
#define pf(a) printf("%d\n",(a))
#define pfc(a) printf("%c",(a))
#define pf64(a) printf("%I64d\n",(a))
#define pff(a) printf("%lf\n",(a))
#define pfs(a) printf("%s\n",(a))
#define pf2(a,b) printf("%d %d\n",(a),(b))
#define pf2s(a,b) printf("%s%s\n",(a),(b));
#define pf2f(a,b) printf("%lf %lf\n",(a),(b))
#define pf264(a,b) printf("%I64d %I64d\n",(a),(b))
#define pfn printf("\n")
#define pfk printf(" ")
#define LL long long

const int N=1000010;
const int M=1000010;
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const int dir4[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
const int dir8[8][2]={{-1,0},{-1,1},{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1}};
const double eps=1e-12;
const double PI=acos(-1.0);

inline int sign(double x){return (x>eps)-(x<-eps);}
template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T> inline T Min(T a,T b){return a<b?a:b;}
template<class T> inline T Max(T a,T b){return a>b?a:b;}
/*************************/

int tot,prime[N+10],f[N+10];

void Getprime()
{
	memset(f,0,sizeof(f));
	tot=0;
	for(int i=2;i<=N;i++)
	{
		if(f[i] == 0)
			prime[tot++]=f[i]=i;
		for(int j=0;j<tot && prime[j]<=f[i] && i*prime[j]<=N;j++)
			f[i*prime[j]]=prime[j];
	}
}



int main(){
    Getprime();
    int n;
    while(sf(n)!=EOF){
    	int p=lower_bound(prime,prime+tot,n)-prime;
    	if(prime[p] != n) p--;
    	pf(p+1);
    }
    return 0;
}

C++: #include <algorithm>
#include <climits>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <stack>
#include <string>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;

/*------------------------------------------------------------------------------*/



int main(){
  int n = 1000000;
  vector<bool> p(n, true);
  p[0] = false;
  p[1] = false;

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

  VI v(n, 0);
  REP(i, 1, n){
    if(p[i]){
      v[i] = v[i-1] + 1;
    } else {
      v[i] = v[i-1];
    }
  }
  while(cin >> N){
    cout << v[N] << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;

int main(){
	int n;
	vector<int> prime;
	int count[100002];
	
	//cout<<"hoge\n";
	prime.push_back(2);
	prime.push_back(3);
	count[1]=0;
	count[2]=1;
	count[3]=2;
	//cout<<"hoge\n";
	for(int i=4;i<10000;i++){
		if(i%2==0){
			count[i]=prime.size();
		}
		else if(i%3==0){
			count[i]=prime.size();
		}
		else{
			count[i]=prime.size()+1;
			prime.push_back(i);
			for(int j=0;j<prime.size()-1;j++){
				if(i%prime[j]==0){
					count[i]--;
					prime.pop_back();
					break;
				}
			}
		}
	}
	//cout<<"hoge";
	/*for(int i=0;i<15;i++){
		cout<< count[i] << endl;
	}*/
	while(cin>>n){
		cout<<count[n]<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
int main(){
	int n;
	while(std::cin>>n){
		int ans=0;
		std::vector<int> vec(n);
		for(int i=0;i<n;i++)vec[i]=1;
		vec[0]=vec[1]=0;
		for(int i=2;i<n;i++){
			if(vec[i] == 1){
				ans++;
				for(int j = 2 * i ; j < n ; j += i){
					vec[j]=0;
				}
			}
		}
		if(n==2)std::cout<<1<<std::endl;
		else std::cout<<ans<<std::endl;
	}

	return 0;
}

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

using namespace std;

int main()
{
    long long n,count=0;
    cin >> n;
    for(long long i=2;i<n;i++){
        long long f;
        for(f=2;f<i;f++){
            if(i%f==0){
                break;
            }
        }
        if(i==f)
            count++;;
    }
    printf("%I64d\n",count);
    return 0;
}

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

int main()
{
	int n, x = 0;
	int countdata[1000];
	while (cin >> n) {
		int count = 0;
		for (int a = 2; a <= n; a++) {
			if (a % 2 != 0 && a % 3 != 0 && a % 5 != 0 && a % 7 != 0) {
				count++;
			}
		}
		countdata[x] = count;
		x++;
	}
	for (int a = 0; a < n; a++) {
		cout << countdata[a] << endl;
	}
}