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++: #define _USE_MATH_DEFINES
#include <iostream> 
#include <math.h>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std; 
int main(){
	int N;
	while (cin >> N){
		int p=log2(N);
		cout << N*p << endl;
	}
	return 0;
}

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

const int ARR_MAX = 1000000;
int fl[ARR_MAX];
int sm[ARR_MAX+1] = {0};

void init_arr();
void isfl(int);

int main(void) {
  int tag;
  init_arr();

  while(1){
    cin >> tag;
    if(tag == 0 || cin.eof()) break;
    isfl(tag);
    cout << sm[tag] << endl;
  }
  return 0;
}

void init_arr(){
  for(int i=0;i<ARR_MAX;i++) fl[i] = 1;
}

void isfl(int tag){
  int i,lim,idx = 2;
  fl[0] = 0;
  fl[1] = 0;

  lim = sqrt(tag);

  while(idx <= lim){
    if(fl[idx] == 1) for(i = idx*2;i<=tag;i+=idx) fl[i] = 0;
    idx++;

  }
  for(int i = 2;i<=tag;i++) sm[i] = sm[i-1] + fl[i];
  return;
}

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

#define rep(i,n) for(int i=2; i<=n; i++)
bool isprime(long long int n){
	rep(i,sqrt(n)){
		if(n%i==0) return false;
	}
	return true;
}
int main(){
	long long int n, ans;
	while(cin >> n){
		ans=0;
		rep(i,n) if(isprime(i)) ans++;
		cout << ans << endl;
	}
    return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-9


bool primes[1000000];

void make_prime(){
	primes[0] = primes[1] = true;
	for(int i=2; i*i<=1000000; i++)if( !primes[i] )
		for(int j=i*2; j<1000000; j+=i)primes[j]=true;
}

int main(){
	int n,ret;
	make_prime();
	while(~scanf("%d",&n)){
		ret = 0;
		for(int i=2; i<=n; i++)if( !primes[i] )ret++;
		printf("%d\n",ret);
	}
	return 0;
}

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


int main()
{
	int n;
	
	while(cin >> n)
	{
		if (n>999999) continue;
		int i, j;
		int k = 0;
		for (i = 2; i <= n; i++)
		{
			int c = 0;
			for(j = 1; j<=i /2; j++)
			{
				if(i % j == 0)
				{
					c++;
					if (c > 1) break;
				}
			}
			if (c == 1)
			{
				k++;
			}
		}
		cout << k << endl;
	}
}

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

bool prime(int n) {
	if (n < 2) return false;
	for (int i = 2; i < sqrt(n) + 1; i++) {
		if (n % i == 0) return false;
	}
	return true;
}

int main() {
	vector<int> v = vector<int>(1, 0);
	for (int i = 1; i < 1000000; i++) {
		if (prime(i)) {
			v.push_back(v.back() + 1);
		} else {
			v.push_back(v.back());
		}
	}
	int n;
	while (cin >> n) {
		cout << v[n] + 1 << endl;
	}
}

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

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;

int t;

int main(){
	int *prime;
	prime = (int *)malloc(1000010*sizeof(t));
	if(prime==NULL) cout<<"no mem\n";
	rep(i,1000010){
		prime[i]=true;
	}
	prime[0]=prime[1]=false;
	for(int i=2;i<1000010;i++){
		if(prime[i]){
			for(int j=i*2;j<1000010;j+=i){
				prime[j]=false;
			}
		}
	}
	//rep(i,30) cout<<i<<" "<<prime[i]<<endl;
	int *sum;
	int num=0;
	sum=(int *)malloc(1000010*sizeof(t));
	if(sum==NULL) cout<<"no mem\n";
	rep(i,1000010){
		if(prime[i]){
			num++;
		}
		sum[i]=num;
	}
	int n;
	while(cin>>n){
		cout<<sum[n]<<endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int n;
const int MAX=1e7+5;
int pri[MAX];
bool py[MAX];
int c0=0;
void isprime()
{
	memset(py,true,sizeof(py));
	int t=sqrt(MAX);
	pri[0]=pri[1]=false;
	for(int i=2;i<=t;i++)
	{
		if(py[i])
		{
			for(int j=2*i;j<=MAX;j+=i)
			py[j]=false;
			pri[c0++]=i;
		}
	}
}
int main()
{
	c0=0;
	isprime();
	while(cin>>n)
	{
		int c=0;
		for(int i=0;i<c0;i++)
		{
			if(pri[i]<=n) c++;
		}
		cout<<c<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <limits>
#include <map>
#include <string>
using namespace std;

bool is_prime(int n){
for(int i=2;i*i<=n;i++){
if(n % i == 0) return false;
}
return n!=1;
}

int main(){
int n;
while(~scanf("%d",&n)){
int* table =  new int[n+1];
fill((int*)table,(int*)table+n+1,1);
table[0]=0;
table[1]=0;

for(int i=2;i<=n;i++){
if(table[i] && !is_prime(i)) {
for(int j=i;j<=n;j+=i){
table[j] = 0;
}
}
}
printf("%d\n",count(table,table+n+1,1));
}
}

C++: // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009
// for ref

#include <iostream>
#include <cstring>
#define Rep(i, b, e)\
    for (int i = (int)b; i < (int)e; i++)

using namespace std;

const int MAXN = 999999;
bool isPrime[MAXN];

int countPrime(int n) {
    memset(isPrime, true, sizeof isPrime);
    Rep(i, 0, 1000)
        isPrime[i] = true;

    isPrime[0] = false;
    isPrime[1] = false;
    // isPrime[2] = true;
    // isPrime[3] = true;

    Rep(i, 2, n) {
        Rep (k, 2, 100) {
            isPrime[i*k] = false;
        }
    }

    int primeCount = 0;
    int j = 0;
    // while (primeCount < n) {     // GS q
    while (j <= n) {
        if (isPrime[j]) {
            // cout << primeCount << " th prime\t";
            // cout << j << endl;
            primeCount++;
        }
        j++;
    }

    return primeCount;
}

int num;

int main()
{
    while (cin >> num) {
        cout << countPrime(num) << endl;
    }
 //   cout << "Hello world!" << endl;
    return 0;
}

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

using namespace std;

int main()
{
int number;
bool TEST;
TEST = true;


cin>> number;
for(int i=2; i < number; i++)

{
if (number%i==0)
TEST = false;
break;

}

if (TEST == false)
cout << number << " is not prime";
else cout << number << " is prime";

}

C++: #include <iostream>
using namespace std;
 
bool IsPrime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i == 0){return false;}
    }
    return true;
}
 
int main(void) {
	int n;
 while(cin >> n){	
    int count = 0;
    for(int i=2;i<=n;i++){
        if(IsPrime(i)) count++;
    }
    cout << count << endl;
    count = 0;
}

    return 0;
}

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

int main(){
    int n;
    while(cin >> n){
        int numOfPrime = 0;
        bool isPrime[n-1];
        for(int i=2;i<=n;++i){
            isPrime[i-2] = true;
        }
        for(int i=2;i<=sqrt(n);++i){
            if(!isPrime[i-2]){
                continue;
            }
            for(int j=i;j<=n;++j){
                if(j%i == 0 && i != j){
                    isPrime[j-2] = false;
                }
            }
        }
        for(int i=2;i<n;++i){
            if(isPrime[i-2]){
                ++numOfPrime;
            }
        }
        cout << numOfPrime << endl;
    }
}