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 := 2; j < i-1; j++ {
				if i%j == 0 && j != 1 {
					flag = true
					//fmt.Println(i, "/", j)
					break
				}
			}
			if !flag {
				count++
			} else {
				flag = false
			}
		}
		fmt.Println(count)
	}
}

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

int main(){
  int a;
  int i, j, k;
  int past=1, a_sqrt;
  int count;
  bool chk[1000000];

  for(i=1; i<1000000; i++) chk[i]=true;
  while(cin>>a){
    count=0;
    if(past>=a){
      for(i=1; i<=a; i++){
        if(chk[i]) count++;
      }
      printf("%d\n", count);
    }
    else {
      a_sqrt=(int)sqrt((double)a);
      for(i=2; i<=a_sqrt; i++){
        k=past/i; k++;
        for(j=k; j<=a/i; j++){
          chk[j*i]=false;
        }
      }
      past=a;
      for(i=1; i<=a; i++){
        if(chk[i]) count++;
      }
      printf("%d\n", count);
    }
  }

  return 0;
}

C++: #include <assert.h>
#include <ctype.h>
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>

#include <algorithm>
#include <complex>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define SZ(a) (int)(a).size()
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define REP(i,n) for (int i=0; i<(n); ++i)
#define ALL(c) c.begin(), c.end()
#define CLR(c,n) memset(c, n, sizeof(c))
#define TR(it, c) for(typeof(c.begin()) it = c.begin();it != c.end(); ++it)
#define CONTAIN(it, c) (c.find(it) != c.end())
typedef vector<int> VI;
typedef pair<int, int> PII;
template <class T> void checkmin(T &a, T b) { if (b<a) a=b; }
template <class T> void checkmax(T &a, T b) { if (b>a) a=b; }
const int INF=0x3F3F3F3F;

const int N=1<<20;
int p[N];
int main(int argc, char *argv[]) {
  p[0] = p[1] = 0;
  fill(p + 2, p+N, 1);
  for (int i = 2; i * i < N; ++i) {
    if (p[i]) {
      for (int j = i * i; j < N; j += i) {
        p[j] = 0;
      }
    }
  }
  FOR(i, 3, N-1) p[i] += p[i-1];
  int n;
  while (scanf("%d", &n) == 1) printf("%d\n", p[n]);
}

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

int main(){
	int n,s,a;
	
	while(cin >> n){
		a=1;
		for(int j=3;j<=n;j+=2){
			s=0;
			for(int i=3;i<j;i+=2){
				if(j%i==0){
					s++;
				}
			}
			if(s==0){
				a++;
			}
		}
		cout << a << "\n";
	}
		
	
return 0;
}

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

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

bool is(float n)
{
	for(int i=2;i<=sqrtf(n);i++)
		if((int)n%i==0)
			return false;
	return true;
}

int main()
{
	int n;
	while(cin>>n)
	{
		int sum=1;
		for(int i=3;i<=n;i++)
			if(is(i)==true)
				sum++;
		cout<<sum<<endl;
	}
}

C++: #include <cstdio>
#define max_n 999999
int prime[max_n];
bool is_prime[max_n+1];
int main(){
    for(int i=0; i<max_n; i++){
        is_prime[i]=true;
    }
    int p = 0;
    is_prime[1]=false;
    is_prime[0]=false;
    for(int i=2;i<max_n;i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j=2*i;j<max_n;j+=i)is_prime[j]=false;
        }
    }
    int n;
    while(scanf("%d",&n)!=EOF){
        printf("%d\n",n);
        int ans = 0;
        for(int i =0; i<max_n; i++){
            ans = i;
            if(prime[i]>n){
                break;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

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

int count_prime( unsigned int const& n )
{
    if ( n <= 0 || 1000000 <= n ) return -1;
    std::vector<bool> memo_prime( n+1, true );
    for ( unsigned int i = 2; i < n; ++i )
    {
        for ( unsigned int j = 2; i*j <= n; ++j )
        {
            memo_prime.at(i*j) = false;
        }
    }
    memo_prime.at(0) = memo_prime.at(1) = false;
    memo_prime.at(2) = true;
    return std::count( memo_prime.begin(), memo_prime.end(), true );
}

int main()
{
    int n;
    while( std::cin >> n )
        std::cout << count_prime(n) << std::endl;
    return 0;
}

C++: #include<iostream>
using namespace std;
#define N 200000
int main()
{
    int a[N]={0},n,i,j,z;
    for(i=2;i<=N/2;i++){
	if(a[i]==0){
	    for(j=2;j*i<=N;j++){
		a[i*j]=1;	     
    	    }
	}
    }
    while((cin>>n)!=0){
    	z=0;
	for(i=2;i<=n;i++){
    	    if(a[i]==0)z++;
	}
	cout<<z<<endl;
    }
    return 0;	
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
using namespace std;

int main(){
  int n,i,j;
  while(cin >> n) {
    if(n==1){
      cout << 0 <<endl;
      continue;
    }
    int k = 0, a[n];
    a[0] = 2;
  
    for (i = 3; i <= n; i = i + 2) {
      for (j = 0; j <= k; j++) {
        if(i % a[j] == 0 ) break;
        if(i <= a[j] * a[j]) {
          k++;
          a[k] =i;
          break;
        }
        
      }
      if(j == k + 1) {
        k++;
        a[k] = i;
      }
    }
    cout << k+1 << endl;
  }
  
  return 0;
}

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

int whether(int num);
int count(int num);

int main(){
	int n=1;
	int a=1;

	while(a==n){
	scanf("%d",&n);
	a = count(n);
	printf("%d\n",a);
	a=n;
}

scanf("%d",&a);
	return 0;
}

int whether(int num){
	int s=sqrt(num);
	int i;
	for(i=3; i<=s; i+=2){ if(num%i==0) return 0; }

	return 1;
}

int count(int num){
	int a=1;
	int i;
	if(num <2){ return 0; }
	for(i=3; i<=num; i+=2){
		a += whether(i);
	}

	return a;
}

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++)
#define rep2(i,n) for(int i=0; i<n; i++)
bool isprime(int n){
	rep(i,sqrt(n)){
		if(n%i==0) return false;
	}
	return true;
}
int main(){
	int n, ans;
	bool table[1000000];
	rep2(i,1000000) table[i]=true;
	rep(i,1000000){
		if(table[i] && isprime(i)){
			rep(j,999999/i) table[i*j]=false;
		}
	}
	while(cin >> n){
		ans=0;
		rep(i,n) if(table[i]) ans++;
		cout << ans << endl;
	}
    return 0;
}

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

int main()
{
	unsigned int  n,j;
	cin >> n;
	unsigned  int num[n],count = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> num[i];
	}
	for(int i = 0; i < n; i++)
	{
		for(j = 2; j <num[i]; j++)
		{
			if((num[i] % j) == 0)
			{
				break;
			}
		}
		if(j == num[i]) count++;
  }
	cout << count << endl;
	return 0;
}

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

int main() {
int b[1000000];
for (int k=0;k<1000001;k++){
	b[k]=0;
}
b[2]=1;
b[3]=1;
b[4]=0;
b[5]=1;
b[6]=0;
b[7]=1;

for (int p=11;p<1000001;p+=2){
int i,a=0 ;
	i=3;
	while(i<sqrt(p)){
		if(p%i==0){
			break;
	}i=i+2;
	}
	if (i>=sqrt(p)){
		a=1;
	}
	b[p]=a;
}
int c[1000000];
for (int l=0;l<1000001;l++){
	c[l+1]=c[l]+b[l+1];
}
int r;
while(cin>>r){
	cout<<c[r]<<endl;
}
	return 0;
}

C++: #include <iostream>

using namespace std;

#define MAX 1000000

int main(){
  int n;
  bool p[MAX];
  p[0] = false;
  p[1] = true;
  for(int i=2;i<MAX;i++)p[i] = true;
  for(int i=2; i*i<MAX;i++){
	if(p[i]){
	  for(int j=i*i;j<=MAX;j=j+i){
		p[j] = false;
	  }
	}
  }
  
  while(cin >> n){
	int cnt = 0;
	for(int i = 0;i<n;i++){
	  if(p[i]) cnt++;
	}
	cout << cnt << endl;
  }
  
  return 0;
}