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>

int ans ;
int N ;
bool prime[1000200] ;

void SE ( ) ;

int main ( ) 
{
	SE ( ) ;
	while ( scanf ( "%d" , &N ) == 1 ) {
		ans = 0 ;
		if ( N > 2 ) {
			ans++ ;
		}
		for ( int i = 3 ; i < N ; i += 2 ) {
			if ( prime[i] == false ) {
				ans++ ;
			}
		}
		printf ( "%d\n" , ans ) ;
	}
	return 0 ;
}

void SE ( )
{
	prime[0] = prime[1] = true ;
	for ( int i = 3 ; i < 1004 ; i += 2 ) {
		if ( prime[i] == false ) {
			for ( int j = i * i ; j < 1000020 ; j += i * 2 ) {
				prime[j] = true ;
			}
		}
	}
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };


/******************************************************************************************/


/*nまでの素数を列挙して配列に保持*/
vector<ll> Eratosthenes(ll n) {

	vector<ll> arr(n);
	for (ll i = 0; i < n; i++) {
		arr[i] = 1;
	}
	arr[0] = arr[1] = 0;
	for (ll i = 2; i < sqrt(n); i++) {
		if (arr[i]) {
			for (ll j = 0; i * (j + 2) < n; j++) {
				arr[i * (j + 2)] = 0;
			}
		}
	}
	return arr;
}


int main() {

	int n;
	
	vector<ll> prime = Eratosthenes(1000005);

	for (int i = 0; i < prime.size()-1; i++)
	{
		prime[i + 1] += prime[i];
	}

	while (cin >> n) {
		cout << prime[n] << endl;
	}

	
	return 0;
}

C++: #include    <iostream>
 
using namespace std;
 
bool F[1000003] = { false };
int DP[80000] = { 0 };
void prepa_Prime();
int count_Prime(int);
 
int main() {
    int n;

    prepa_Prime();
    while (cin >> n) {
        cout << count_Prime(n) << endl;;
    }

    return 0;
}
 
void prepa_Prime() {
    int i, c = 2;
 
    F[0] = F[1] = true;
    DP[0] = 1;
    DP[1] = 2;
    for (i = 4; i <= 1000003; i += 2) { F[i] = true; }

    for (i = 3; i <= 1000003; i += 2) {
        if (F[i] == false) {
            DP[c++] = i;
            for (int j = i * 2; j <= 1000003; j += i) {
                F[j] = true;
            }
        }
    }
}

int count_Prime(int n) {
    int i = 0;
    for (i; DP[i + 1] <= n; i++) {}
    return i;
}

C++: #include <iostream>
#include <list>
#include <algorithm>

int main(){
	int NUM;
	while(std::cin >> NUM){
		std::list<int> numList,primeList;
		for(int i=2;i<=NUM;++i){
			numList.push_back(i);
		}
	
		for(int i=numList.front();i<std::sqrt(NUM);i=numList.front()){
			primeList.push_back(i);
			numList.erase(std::remove_if(numList.begin(),numList.end(),[&](int num){return num%i==0;}),numList.end());
		}
		int cnt=numList.size()+primeList.size();	
		std::cout << cnt << std::endl;
		}
	return 0;
}

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


using namespace std;



bool isPrime(int num) {
	int root = (int)sqrt(num);
	for (int i = 3; i <= root; i += 2) {
		if (num % i == 0)return false;
	}
	return true;
}

int main() {

	int num;
	while (cin >> num) {
		int count = 0;
		if (num >= 2)count++;

		for (int i = 3; i <= num; i += 2) {
			if (isPrime(i))count++;
		}
		printf("%d\n",count);
	}


	
	//std::system("pause");
	return 0;
}

C++: /*****include*****/
#include <iostream>
#include <fstream>

/*****デバッグ定義*****/
//#define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/
/*****その他関数置き場*****/

/*****main関数*****/
int main(){
	/*****ファイルオープン*****/
#ifdef DEBUG
	ofstream fout("output.txt");
	ifstream fin("input.txt");
	if(!fout || !fin){
		cout << "Can't open the file.\n";
		return;
	}
#endif
	/*****変数置き場*****/
	
	bool *prime;
	int num;
	int n;
	
	/*****処理部*****/
	while(1){
		cin >> n;
		prime = new bool [n+1];
		for(int i=0;i<n+1;i++){
			prime[i] = true;
		}
		prime[0] = prime[1] = false;
		for(int i=0;i<n+1;i++){
			if(prime[i]){
				for(int j=2*i;j<n+1;j+=i){
					prime[j] = false;
				}
			}
		}
		num = 0;
		for(int i=0;i<n+1;i++){
			if(prime[i])	num++;
		}
		cout << num << endl;
		delete prime;
	}
	/*****処理終了後*****/
#ifdef DEBUG
	fout.close();
	fin.close();
#endif
	return 0;
}

C++: #include<cstdio>
#include<vector>
#include<cmath>
using namespace std;
int main(){
    int n,ans=0;
    while(scanf("%d",&n)!=-1){
        vector<bool> tab(n+1,true);
        int upto=sqrt(n);
        for(int i=2;i<=upto;i++){
            if(tab[i]){
                for(int j=i*2;j<=n;j+=i){
                    tab[j]=false;
                }
            }
        }
        for(int i=2;i<=n;i++){
            if(tab[i]) ans++;
        }
        printf("%d\n",ans);
    }
}

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

using namespace std;

int prime(int n);

int main(){
  vector<int> inp;
  int num,pri;					
  int i=0;

  while(cin>>num){
    if(num <= 1)inp.push_back(0);
    else{
      pri = prime(num);
      inp.push_back(pri);
    }
    i++;
  }
  int j = 0;
  while(j < i){
    cout<<inp[j]<<endl;
    j++;
  }
}

int prime(int num){
  int count=0;
  bool judge=0;
  for(int i = 2; i <= num; i++){
    judge =1;
    for(int j= 2; j < i; j++){
      if(i%j == 0)judge =0;
    }
    if(judge==1)count = count +1; 
  }
  return count;
}

C++: #include <iostream>
using namespace std;
int s[10000],m[1000000],i,j,n=0;
int main() {
	for (i=2; i<100000 ; 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++) ;
		cout << j << endl;
	}
cin >> j;
return 0;
}

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

int main(){
	long long int prime[999999];
	long long int ptr=0;
	
	prime[ptr++]=2;
	prime[ptr++]=3;

	for(int no = 5 ; no <=  999999 ; no += 2){
		int flag = 0;
		for (int i = 1; prime[i] * prime[i] <= no ; i++){
			if(no % prime[i] == 0){
				flag=1;
				break;
			}
		}
		if(!flag)
			prime[ptr++] = no;
	}
	
	
	int n,co=0;
	while(cin>>n){
		co=0;
		for(int i=0; prime[i] <= n ;i++){
			co++;
		}
		cout<<co <<endl;
	}
}

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

using namespace std;

constexpr int MAX = 1000000;

int main()
{
    vector<bool> prime_list(MAX, true);
    prime_list.at(0) = false;
    prime_list.at(1) = false;
    for(int i = 2; i * i < MAX; ++i)
    {
        if(!prime_list.at(i))
            continue;
        for(int j = 2; i * j < MAX; ++j)
            prime_list.at(i * j) = false;
    }

    int num;
    int count;
    while(cin >> num)
    {
        count = 0;
        for(int i = 2; i < num; ++i)
        {
            if(prime_list.at(i))
                count++;
        }
        cout << count << endl;
    }
}