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<iostream>
using namespace std;
// n < 1000000

int is_it_primeNum(int n)
{
	int a = 1;
	if (n == 0 || n == 1)
		return 0;
	else{ 
		for(int i=2;i<n;i++){
			if (n%i==0){
				a = 0;
				break;}
		}
	}
	return a;
}
int how_much_primeNum(int n)
{
	int ans = 0;
	for(int i=2;i<=n;i++){
		ans += is_it_primeNum(i);
	}
	return ans;
}

int main()
{
	int n;
	while(cin>>n)
		cout << how_much_primeNum(n) << endl;
}

C++: #include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main(){
  int n,k;
  while(cin>>n){
    int num=0;
    if(n==1)cout<<num<<endl;
    else{
      for(int i=3;i<=n;i+=2){
	k=0;
	for(int j=3;j<=sqrt(i);j+=2){
	  if(i%j==0){
	    k=1;
	    break;
	  }
	}
	if(k==0)num++;
      }
      cout<<num+1<<endl;
    }
  }
  return 0;
}

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

inline bool check(int n)
{
	for (int i = 2; i*i <= n; i++)
	{
		if (n % i == 0) return false;
	}
	return true;
}

int main()
{
	int n[1000000] = {};
	int x;
	bool f;
	
	for (int i = 2; i <= 1000000; i++)
	{
		f = check(i);
		if (f == true) n[i] = n[i - 1] + 1;
		else n[i] = n[i - 1];
	}

	while (cin >> x)
		cout << n[x] << endl;
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

struct Eratosthenes {
	// 1-indexedで検索可能
  vector< bool > prime;
  Eratosthenes(int _size) {
    init(_size);
  }	
	
  void init(int n) {
    prime.resize(n + 1);
    for(int i=0; i<prime.size(); ++i) prime[i] = true;
    prime[0] = prime[1] = false;
    for(int i=2; i*i<=n; i++) {
      if (prime[i]) {
        for (int j=0; i*(j + 2)<n; ++j) {
					prime[i*(j+2)] = false;
				}
      }
    }
  }

	// 整数nを素因数分解して, その要素がいくつあるかを返す
	vector< pair< int, int > > prime_factorize(int n) {
		vector< pair< int, int > > res;
		for (int p=2; p*p<=n; ++p) {
			if (n%p != 0) continue;
			int num = 0;
			while (n%p == 0) ++num, n /= p;
			res.push_back(make_pair(p, num));
		}
		if (n != 1) res.push_back(make_pair(n, 1));
		return res;
	}
};

int main() {
	Eratosthenes e(1010101);
  int n;
	while(scanf("%d",&n) != EOF){
		int ans=0;
		for(int i=1;i<=n;++i){
			if(e.prime[i]) {
				++ans;
			}
		}
		cout<<ans<<endl;
	}
  return 0;
}

C++: #include <iostream>
//#include <vector>
//#include <math.h>
//#include <string>
//#include <cmath>

int main(void);
int count_prime_number(int n);

int main(){
	int n;
	int cnt = 0;
	int result[30];

	//while (cnt < 3){
		//std::cin >> n;
	while (std::cin >> n){
		result[cnt] = count_prime_number(n);
		cnt++;
	}

	for (int i = 0; i < cnt; i++){
		std::cout << result[i] << std::endl;
	}

	//while (1);
	return 0;
}


//0..nまでの素数の個数を出力する
//args:数値
//return:素数の個数
int count_prime_number(int n){
	int rtn = 0;

	//2だけ個別チェック
	if (n >= 2){
		rtn++;
	}

	for (int i = 3; i <= n; i+= 2)
	{
		bool is_prime_num = true;
		for (int j = 3; j <= sqrt(i); j+= 2)		//ルートi以上のiの約数はルートi以下のiの約数と対になっているので範囲はルートiまででいい
		{
			if (i % j == 0)
			{
				is_prime_num = false;
				break;
			}
		}

		if (is_prime_num){
			rtn++;

			//デバッグ
			//std::cout << i << std::endl;
		}
	}

	return rtn;
}

C++: #include<iostream>
#include<string.h>
int main(){for(int m,n,o,c,d,e,i;!(std::cin>>n).eof();){if(n<3)e=n>1;else{bool*v=new bool[c=(n&1?n:--n)/2+1];memset(v,1,c);for(i=m=e=1;i<c;i++){for(m=i;m<c&&!v[m];)m++;if(m==c)break;e++;for(d=o=m*2+1;d<n+1;d+=o*2)v[d/2]=0;if(n<o*o)break;}for(i=1;i<c;)e+=v[i++];delete[]v;}printf("%d\n",e);}}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main(){
	int n,cnt=0,ans,sosu[100003]={0};
	
	for(int i=2;i<100002;i++){
		bool flag=true;
		for(int j=2;j<=sqrt(i);j++){
			if(i%j==0)flag=false;
		}
		/*if(flag){
		cnt++;
		sosu[i]=cnt;
		}*/
		sosu[i]=(flag)? cnt++ : cnt;		
	}
	//for(int i=0;i<30;i++)cout<<sosu[i]<<" ";
	while(cin>>n){
	cout<<sosu[n]<<endl;
	}
    return 0;
}

C++: #include<stdio.h>
bool b[1000000];

int main(void)
{
    int a,n,i;
    int count=0;
    int f=1;

    for(i=3;i<1000000;i+=2){
        f=1;
        for(a=2;a*a<=i;a++){
            if(i%a == 0){
                f=0;
                break;

            }
        }
        if(f==1){
            b[i]=1;
        }
    }
    b[2]=1;

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

    printf("%d\n",count);
    count=0;
    }
    return 0;
}

C++: #include <stdio.h>

int main()
{
    unsigned long long int isprime ,n,i,x,z,sum=0;
    scanf("%llu",&x);
    for(n=2;n<=x;n++)
    {
        if(n==2)
        {
            sum++;
        }
        else
        {
            isprime=0;

            for(i=2;i<n;i++)
            {
                if(n%i==0)
                {
                    isprime=1;
                    break;
                }
            }
         }
        if(isprime == 0)
        {
            sum++;
        }
    }
    printf("%llu\n",sum);
    return 0;
}

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 < 1000200 ; j += i * 2 ) {
				prime[j] = true ;
			}
		}
	}
}

C++: #include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include <sstream>
using namespace std;
int main(void){
    int n,ans,i;
    while(cin >> n){
        ans = 0;
        if(n < 2){
            cout << "0" << endl;
            continue;
        }else if(n == 2){
            cout << "1" << endl;
            continue;
        }else{
            ans++;
        }
        for(i = 3; i <= n; i += 2){
            double sqrti = sqrt(i);
            if(ceil(sqrti) == floor(sqrti)){
                continue;
            }
            ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;


int main()
{
	int n;
	vector<int> prime;
	
	for(int i=0;i<1000000;i++)
		prime.push_back(1);
	
	prime[0]=prime[1]=0;
	
	for(int i=0;i<1000000;i++)
	{
		if(prime[i]==1)
		{
//			cout << i << endl;
			
			for(int j=2;i*j<1000000;j++)
			{
				prime[i*j]=0;
//				cout << i*j <<endl;
			}
		}
	}
	
	
	for(;cin >> n;)
	{
		int ans=0;
		
		for(int i=0;i<=n;i++)
			if(prime[i]==1)
				ans++;
		cout << ans << endl;
	}
}

C++: #include <iostream>
#include<vector>
using namespace std;
vector<int> p;
void makeprimelist(int n)
{
	bool *isp=new bool[++n];
	for(int i=0;i<n;i++)isp[i]=true;
	for(int i=2;i<=n;i++)
	{
		if(isp[i])
		{
			p.push_back(i);
			for(int j=2;j<=n/i;j++)isp[i*j]=false;
		}
	}
	return;
}

int main() {
	int n;
	while(cin>>n)
	{
		p.clear();
		makeprimelist(n);
		cout<<p.size()<<endl;
	}
	return 0;
}