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>
#include <cmath>

using namespace std;

const int M = 1e7+10;
bool isPrime[M];

void sieve(){
    for(int i=2;i<M;i++) isPrime[i] = true;
    for(int i=2;i*i<M;i++){
        if(!isPrime[i]) continue;
        for(int j=2*i;j<M;j+=i){
            isPrime[j] = false;
        }
    }
}

int main(){
    sieve();
    int n;
    while(cin >> n){
        int c = 0;
        for(int i=0;i<=n;i++){
            if(isPrime[i]) c++;
        }
        cout << c << endl;
    }
}

C++: #include<iostream>
#define MAX 1000000

using namespace std;

bool prime[MAX+1];
int T[MAX];

void eratos( int n ){
    for ( int i = 0; i < n; i++ ) prime[i] = false;
    for ( int i = 3; i <= n; i += 2 ) prime[i] = true;
    prime[2] = true;
    for ( int i = 3, limit = (int)sqrt(n); i <= limit; i += 2 ) {
	if ( !prime[i] ) continue;
	for ( int j = i * i, k = i * 2; j <= n; j += k ) prime[j] = false;
    }
}

void initialize(){
    eratos( MAX );
    for ( int i = 0; i < MAX; i++ ){
	T[i] = T[i - 1];
	if ( prime[i] ) T[i]++;
    }
}

main(){
    initialize();
    int n;
    while ( cin >> n ) cout << T[n] << endl;
}

C++: #include <iostream>
#include <bitset>
#include <vector>
#include <cmath>
#define	MAXPRIME	999999
using namespace std;

typedef unsigned int uint;

void setPrimeFlag(bool *primeFlag, uint maxPrime) {
	uint sq = (uint)sqrt((double)maxPrime) + 1;
	for (uint i = 2; i <= maxPrime; ++i) { primeFlag[i] = true; }
	primeFlag[0] = primeFlag[1] = false;
	for (uint i = 2; i <= sq; ++i) {
		if (primeFlag[i]) {
			for (uint j = i + i; j <= maxPrime; j += i) {
				primeFlag[j] = false;
			}
		}
	}
}

template <class ARR> void setPrimeArray(ARR &primeArray, uint maxPrime) {
	bool *primeFlag = new bool[maxPrime + 1];
	setPrimeFlag(primeFlag, maxPrime);

	primeArray.clear();
	for (uint i = 2; i <= maxPrime; ++i) {
		if (primeFlag[i]) {
			primeArray.push_back(i);
		}
	}
	delete [] primeFlag;
}

int main() {
	vector<uint> primeArray;
	setPrimeArray<vector<uint>>(primeArray, MAXPRIME + 1);

	for (;;) {
		uint n, num;
		cin >> n;
		if (cin.eof()) { break; }

		for (num = 0; num < primeArray.size() && primeArray[num] <= n; ++num);

		cout << num << endl;
	}

	return 0;
}

C++: #include<cstdio>

#define MAX 1200000
using namespace std;
int prim[1200100];
int prima[1200100];
int main() {
    int n, i, x = 0;
    for (i = 2; i <= MAX; i++) {
        prim[i] = i;
    }
    for (i = 2; i <= MAX; i++) {
        if (prim[i] != 0) {
                  prima[x] = prim[i];
                  x+= 1;
                  int j = i;
                  while ( j <= MAX) {
                        prim[j] = 0;
                        j+= i;
                  }
        }
    }
    while (scanf("%d", &n) != EOF) {
          int a = 0;
          while ( prima[a] <= n) {
                a++;
          }
          printf("%d\n", a);
    }
    return 0;
}

C++: #include<stdio.h> int main(void){ int a,b,r,ans,a1,b1; double c; while(scanf("%d %d",&a,&b)!=EOF){ a1=a,b1=b; while(1){ r=a%b; if(r==0){ ans=b; break; }else{ a=b; b=r; } } c=(double)(a1)*(double)(b1)/(double)(ans); printf("%d %.0f\n",ans,c); } return 0; }

C++: #include<bits/stdc++.h>
#include<iostream>
#define LIM 999999
using namespace std;
long long int i,j,a,odd;
bool prime[LIM];
long long int arr[999999];
void sieve()
{
    
    arr[a++]=2;
    for(i=3;i<=LIM;i+=2)
    {
        if(!prime[i])
        {
            arr[a++]=i;
            if(i*i<=LIM)
            {
                odd=i;
                
                for(j=i*i;j<=LIM;j=i*odd)
                {
                    prime[j]=true;
                    odd+=2;
                }
            }
        }
    }
}
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    sieve();
    long long int k, num, count = 0;
    k=0;
    while(scanf("%lld", &num)!=EOF)
    {
        k=0;
        count = 0;

        for(int i=1; i<=num; i++)
        {
            if(i == arr[k])
                {
                    count++;
                    k++;
                }
        }
        printf("%lld\n", count);
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(void) {
  int n, num, p[100000] = {};
  bool flag;
  p[0] = 2;
  while(cin >> n) {
    if(n == 1) {
      num = 0;
    } else {
      num = 1;
    }
    for(int i = 2; i < n+1; i++) {
      flag = false;
      for(int j = 0; j < num; j++) {
        if(i % p[j] == 0) {
          flag = true;
          break;
        }
      }
      if(flag == false) {
        p[num] = i;
        num++;
      }
    }
    cout << num << '\n';
  }

  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
#define FOR(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

int p[1000010];

int main(){
	p[0]=p[1]=1;
	rep(i,1000000){
		if(p[i]==0)
			for(int j=2*i;j<1000000;j+=i)
				p[j]=1;
	}
	int n;
	for(;cin>>n;){
	int r=0;
	rep(i,n)
	if(p[i]==0)r++;
	cout<<r<<endl;
	}
	return 0;
}

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

int main();
int count_prime_number(int n);
std::vector<int> return_prime_number(int n);

//最初に素数リストを作成し、入力された値に対してリストを参照する。
int main(){
	std::vector<int> prime_numbers;		//素数リスト
	int input;
	std::vector<int> answer;

	prime_numbers = return_prime_number(999999);
	//for (int i = 0; i < 3; i++){
	//std::cin >> input;
	while (std::cin >> input){
		//素数の探索
		for (int i = 0; i < input; i++){
			if (input == prime_numbers[i]){
				answer.push_back(i + 1);
				break;
			}
			else if (input < prime_numbers[i]){
				answer.push_back(i);
				break;
			}
			else{
				//何もしない
			}
		}
	}

	for (int i = 0; i < answer.size(); i++){
		std::cout << answer[i] << std::endl;
	}

	//while (1);
	return 0;
}


//入力のたびに素数のチェックをする
/*
int main(){
	int input;
	std::vector<int> answer;
	
	//for (int i = 0; i < 3; i++){
		//std::cin >> input;
	while (std::cin >> input){
		answer.push_back(count_prime_number(input));
	}

	for (int i = 0; i < answer.size(); i++){
		std::cout << answer[i] << std::endl;
	}

	//while (1);
	return 0;
}
*/

/**
* nまでの素数の個数を出力する
* args:数値n
* return:素数の個数
* 参考:http://tsg.ne.jp/TT/tsg/c/mansaku/P01.html
*/
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;
}

/**
* nまでの素数を返す
* args:任意の数値n
* return:素数を格納したvector
*/
std::vector<int> return_prime_number(int n){
	std::vector<int> rtn;

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

	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.push_back(i);

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

	return rtn;
}