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 get_num_of_under_n(int n) {
	bool* numbers = new bool[n + 1];
	for (int i = 2; i < n + 1; i++) {
		numbers[i] = true;
	}
	for (int i = 2; i < sqrt(n); i++) {
		if (numbers[i] == true) {
			for (int j = 0; i*(j + 2) <= n; j++) {
				numbers[i*(j + 2)] = false;
			}
		}
	}
	int ans = 0;
	for (int i = 2; i < n + 1; i++) {
		if (numbers[i] == true)ans++;
	}
	return ans;
}
int main() {
	int n;
	while (cin>>n) {
		cout << get_num_of_under_n(n)<<endl;
	}
}

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

int main(){
 int n,i,j,x,counter;
 cin >> n;
 counter = 0;
 
 for (i = 1; i <= n; i++) {
   x = 0;
   
   for (j = 1; j <= i; j++) {
     if (i % j == 0) x++;
   }
   
   if (x == 2) counter++;
 }
 
 cout << counter << endl;
 
 return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <string>
#include <string.h>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main (void)
{
	long a[10000],co = 3;

	a[0] = 2;
	a[1] = 3;
	a[2] = 5;
	a[3] = 7;
	for (long long i = 8; i < 100000; i++)
	{
		if (i % 2 != 0 && i % 3 != 0)
		{
			if (i % 5 != 0 && i % 7 != 0)
			{
				co += 1;
				a[co] = i;
			}
		}
	}

	long long n,co2;

	while (cin >> n)
	{
		co2 = 0;
		for (long j = 0; j < co + 1; j++)
		{
			if (a[j] > n)
			{
				break;
			}
			co2 += 1;
		}

		cout << co2 << endl;
	}
}

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

int main(){
	int m=0,n;
	cin>>n;
    for(int i=1;i<=n;i++){
    	int s=0;
    	if(i==1)s=1;
    	if(i>3){
    		for(int j=2;j<=sqrt(n);j++){
    			if(i%j==0)s=1;
    		}
    	}
    	if(s==0)m++;
    }
	cout<<m<<endl;
	return 0;
}

C++: #include<bits/stdc++.h>
#define ll long long
#define pi acos(-1)
#define MAXN 1000010
#define inf 0x3f3f3f3f
using namespace std;
typedef pair<int,int>P;
bool prime[MAXN];
int cnt[MAXN];
void init()
{
	memset(prime, true, sizeof(prime));
	prime[1] = false;
	for(int i = 2; i < MAXN; i++)
	{
		if(prime[i])
		for(int j = i * 2; j < MAXN; j += i)
		prime[j] = false;
	}
	for(int i = 1; i < MAXN; i++)
	if(prime[i])
	cnt[i] = cnt[i - 1] + 1;
	else
	cnt[i] = cnt[i - 1];
}
int main()
{
	int n;
	init(); 
	while( cin >> n)
	{
		cout << cnt[n] << endl;
	}
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
  int n;
  int cont;
  while(scanf("%d",&n)!=EOF){
    int a[n];
    for(int i=0;i<n;i++){
      a[i]=1;        //1 素数　０素数ではない
    }
    a[0]=0;
    cont=0;
    for(int i=2;i<=sqrt(n);i++){
      if(a[i-1]==1){
	for(int j=2;i*j<=n;j++){
	  a[i*j-1]=0;
	}
      }
    }
    for(int i=0;i<n;i++){
      if(a[i]==1)cont++;
    }
    cout<<cont<<endl;
  }
}

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

int isPrime (int n) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) return 0;
    }
    return 1;
}

int main() {
    int dp[1000100] = {0};
    for (int i = 2; i <= 1000000; i++) {
        if (isPrime(i)) dp[i] = dp[i - 1] + 1;
        else dp[i] = dp[i - 1];
    }

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

C++: #include<iostream>
#include<cstdio>
using namespace std;
#define len 200000
int prime[len];
int a; 
bool mark[len];

void f()
{
    a=0;
    long long int i,j;
    for( i=0; i<len; i++)
    {
        mark[i]=false;
    }
    for( i=2; i<len; i++)
    {
        if(mark[i]==true)  
            continue;
        else
        {
            prime[a++]=i;
            for( j=i*i; j<len; j+=i)
            {
                mark[j]=true;
            }
        }
    }
}
int main()
{
    f();
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        printf("%d\n",prime[n-1]);
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <fstream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 0x3f3f3f3f
#define inff -30000000
using namespace std;
typedef long long ll;
const int MAXN=1e5+10;
const int MAX=1e6+10;
int prime[MAX];
bool notprime[MAX];
int num=0;
void init(){
    memset(notprime,0,sizeof(notprime));
    for(int i=2;i*i<=MAX;i++){
        if(!notprime[i]){
            prime[num++]=i;
            for(int j=i*i;j<=MAX;j+=i)
                notprime[j]=1;
        }
    }
}
int main(){
    #ifdef SIYU
    freopen("in.txt","r",stdin);
    #endif // SIYU
    int n;
    init();
    while(cin>>n){
        int *p=upper_bound(prime,prime+num,n);
        cout<<"*"<<*p<<endl;
        int ans=p-prime;
        cout<<ans<<endl;
    }
    return 0;
}

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

	bool is_prime[1000000];
	int n_prime[1000000];
int main()
{
	
	is_prime[0]=is_prime[1]=false;
	for(int i=0; i<1000000; i++){
		is_prime[i]=true;
	}
	
	for(int i=0; i<1000000; i++){
		if(is_prime[i]){
			for(int j=i*i; j<1000000; j+=i){
				is_prime[j]=false;
			}
		}
	}


	int cnt=0;
	for(int i=0; i<1000000; i++){
		if(is_prime[i]){
			cnt++;
		}
		n_prime[i]=cnt;
	}

		int n;
		cin>>n;

	
		cout<<n_prime[n]<<endl;
	
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;

#define MAX (1000000)
int main(){
  vector<bool> isP(MAX,true);
  vector<int>  ans(MAX,0);
  int n;
  isP[0] = isP[1] = false;
  for(int i=2; i<MAX; i++)
    if(isP[i]){
      ans[i] = ans[i-1] + 1; 
      for(int j=i+i; j<MAX; j+=i)
	isP[j] = false;
    }else{
      ans[i] = ans[i-1];
    }
  
  while(cin>>n) cout<<ans[n]<<endl;
  return 0;
}

C++: #include<stdio.h>
int main ()
{
    int n,i,m,sum;
    while(1)
    {
        sum=0;
        scanf("%d",&n);
        for(m=2;m<=n;m++)
        {
            for(i=2;i<=m;i++)
            {
                if(m%i==0 && i<m)
                {
                    break;
                }
                if(i==m)
                {
                    sum=sum+1;
                }
            }
        }
        printf("%d\n",sum);
    }
    return 0;
}

C++: #include<iostream>
#include<stack>
using namespace std;
int main() {
	int n, ans = 0, i, count = 0,count2=0;
	while (cin >> n) {
		for (i = 2; i <= n; i++) {
			for (int j = 2; j <= i; j++) {
				if (i % 2 != 0 && i % 3 != 0 && i % 5 !=0 && i%7 != 0) {
					count = 1;
					break;
				}
				if (i > 11) {
					if (i % 2 == 0 || i % 3 == 0 || i % 5 == 0 || i % 7 == 0) {
						count = 0;
						break;
					}
				}
				if (i%j == 0) {
					count++;
				}
				if (i%j != 0) {
					count2++;
				}
				if (count >= 2 ) {
					break;
				}
			}
			if (count == 1) {
				ans++;
			}
			count = 0;
		}
		cout << ans << endl;
		ans = 0;
	}
	return 0;
}