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++: #include<iostream>
using namespace std;
bool F(int n)
{
	bool r=true;
	for(int i=2;i<n;i++)
	{
		if(n%i==0){
			r=false;
			break;
		}
	
	}	
	return r;
}

int main()
{
	int number=0;
	int result=0;
	while(1)
	{
		result=0;
		cin>>number;
		for(int i=number;i>=2;i--)
		{
			if(F(i)==true)
				result++;
		}
		cout << result <<endl;
	}
	return 0;
}

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

const int MAX_N = 10000000, sqrt_N = 1000;
bool prime[MAX_N];
int wei[1000000];

int main()
{
  int N, i, j, k;

  for (i = 1; i <= 5; i += 4){
    for (j = i; j <= sqrt_N; j += 6){
      for (k = 1; k <= sqrt_N && (N = 4 * k * k + j * j) <= N; ++k){
        prime[N] = !prime[N];
      }
      for (k = j + 1; k <= sqrt_N && (N = 3 * k * k - j * j) <= N; k += 2){
        prime[N] = !prime[N];
      }
    }
  }
  for (i = 2; i <= 4; i += 2){
    for (j = i; j <= sqrt_N; j += 6){
      for (k = 1; k <= sqrt_N && (N = 3 * k * k + j * j) <= N; k += 2){
        prime[N] = !prime[N];
      }
      for (k = j + 1; k <= sqrt_N && (N = 3 * k * k - j * j) <= N; k += 2){
        prime[N] = !prime[N];
      }
    }
  }
  for (i = 3; i <= sqrt_N; i += 6){
    for (j = 1; j <= 2; ++j){
      for (k = j; k <= sqrt_N && (N = 4 * k * k + i * i) <= N; k += 3){
        prime[N] = !prime[N];
      }
    }
  }
  for (i = 5; i <= sqrt_N; ++i){
    if (prime[i]){
      for (j = i * i; j <= N; j += i * i){
        prime[j] = false;
      }
    }
  }
  prime[2] = prime[3] = true;

  for (i = 2; i < 1000000; ++i){
    wei[i] += wei[i - 1];
    if (prime[i]) wei[i]++;
  }

  while (cin >> N) cout << wei[N] << '\n';
  return 0;
}

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

typedef long long LL;
using namespace std;

const int X = 1000001;
bool Find[X];

void init(){
  for(int i=0;i<X;i++){
    Find[i] = false;
  }
  for(int i=2;i<=sqrt(X);i++){
    if(Find[i])continue;
    for(int j=i+1;j<X;j++){
      if(Find[j])continue;
      if(j%i==0)Find[j]=true;
    }
  }
}

int main(){
  init();
  int n;
  while(cin >> n){
    int answer = 0;
    for(int i=2;i<n+1;i++){
      cout << Find[i] <<endl;
      if(!Find[i])answer++;
    }
    cout << answer << endl;
  }
  return 0;
}

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

int is_prime(int n){
    int i;
    int flag = 0;
    for(i=2; i<n; i++){
        if(n%i==0) { flag=1; break; }
    }
    return (flag==1)?0:1;
}


int main(){
	int i, j, n, num = 0, count = 0;

	while(cin >> n){
		count = 0;
		for(i = 1; i <= n; i++){
			if(is_prime(i) == 1 && i != 1) count ++;
		}
		cout << count << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
using namespace std;

int main(){
  int n;
  while(cin >> n){
    int ans=0;
    vector<int> vec;
    vec.emplace_back(2);
    for(int i = 3; i<=n; i+=2){
      bool isPrimeN = true;
      for(int j=3; j<=floor(sqrt(i)); j++){
        if(i%j==0){
          isPrimeN = false;
          break;
        }
      }
      if(isPrimeN){
        vec.emplace_back(i);
      }
    }
    cout << vec.size() << endl;;
  }
  return 0;
}

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

int main(){
        int n;
        int d; //素数を入れるための添字
        bool count; //割りきれるかどうかの判定
        int number[400000]; //素数を入れておく
        number[0] = 2;
        
        
        while(cin >> n != 0){
                d = 0;
                for(int i = 3; i <= n; i++){
                        count = true;
                        for(int j = 0; j <= d; j++)
                                if(i % number[j] == 0)
                                        count = false;
                        if(count == true){
                                d++;
                                number[d] = i;
                        }
                }
        cout << d+1 << endl;
        }
}

C++: #include <iostream>
#include <cmath>
using namespace std;
bool prime(int num){
	if(num<2)return false;
	else if(num==2)return true;
	else if(num%2==0)return false;
	double sqrtNum = sqrt((double)num);
	for(int i=3;i<=num;i++){
		if(num%i==0)return false;
	}
	num=0;
	return true;
}
int main(){
	int n,count=0;
	while(cin>>n){
		for(int ii=1;ii<=n;ii++){
		count+=prime(ii);
		}
		cout<<count<<endl;
		count=0;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int n;
const int MAX=1e6+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;
		}
	}
	for(int i=2;i<=MAX;i++)
	{
		if(py[i]) 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++;continue;}
			break;
		}
		cout<<c<<endl;
	}
	return 0;
}

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

int main(void){
	int array[30]={ },n;
	for(int* ite=array;cin>>*ite;ite++);
	int max=*(max_element(array,array+30));
	bool* hurui = new bool[max+1];
	fill(hurui,hurui+max+1,true);
	hurui[0]=hurui[1]=false;
	for(int i=2;i<max;i++){
		if(!hurui[i]) continue;
		for(int j=i*2;j<max;j+=i)
			hurui[j]=false;
	}
	for(int* ite=array;*ite;ite++)
		cout << count(hurui+1,hurui+1+(*ite),true) <<endl;
	delete[] hurui;
}

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

using namespace std;

#define MAX_N 99999
#define MAX_D 30

bool prime_check(int n, int k = 2)
{
	if (n < k * k) { return true; }

	if (n % k == 0) { return false; }

	return prime_check(n, k + 1);
}

int main()
{
	int n;

	bool isprime[MAX_N + 1];

	for (int i = 2; i < MAX_N + 1; i++)
	{
		isprime[i] = prime_check(i);
	}

	while (cin >> n)
	{
		cout << count(isprime + 2, isprime + n + 1, true) << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>

using namespace std;
const int maxx = 1000000;
bool is_prime[maxx];
int prime[maxx];
int a,cnt = 0;
int main()
{
    memset(is_prime,true,sizeof is_prime);
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i * i < maxx; i ++ )
    {
        if(is_prime[i])
        {
            prime[cnt++]=i;
            for(int j = i*2;j < maxx; j+=i ) is_prime[j] = false;
        }
    }
    while(scanf("%d",&a)!=EOF)
    {
        int k = upper_bound(prime,prime+cnt,a) - prime;
        printf("%d\n",k);

    }

    return 0;
}

C++: #include <iostream>
using namespace std;
 
int main() {
	int N;
	bool is_prime[1000000];
	is_prime[0]=0; is_prime[1]=0;
	for(int i=2;i<1000000; i++){
		is_prime[i]=1;
	}
 
	for(int s=2; s<1000000; s++){
		if(is_prime[s]==1){	
		for(long long i=s*s; i<1000000; i+=s){
		is_prime[i]=0;	
 
		}
		}
	}
 
	while(cin >> N){
 
		int ans=0;
		for(int i=2; i<N+1; i++){
			ans+=is_prime[i];
		}
		cout << ans <<endl;
 
	}
return 0;
}

C++: #include <iostream>
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;
int res;
scanf("%d",&n);
for(int i=2;i<=n;i++){
if(is_prime(n)) res++;
}
printf("%d\n",res);
}