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;
int whether(int num);
int count(int num);
int main(){
    int n;
    while(cin >> n){
        cout << count(n)+1<<endl;
    }
    return 0;
}

int whether(int num){//if num is prime, 1
    int s=sqrt(num);
    for(int i=3; i<=s; i+=2){
        if(num%i==0){ return 0; }
    }
    return 1;
}
int count(int num){
    if(num==99) return 24;
    if(num==999) return 167;
    if(num==9999) return 1228;
    if(num==99999) return 9591;
    if(num<2) return 0;
    if(num==2) return 1;
    if(num%2==0) return count(num-1);
    int a;
    a=whether(num) +count(num-2);
    return a;
}

C++: #include<iostream>
int main(){
	int n,m,l;
	while(1){
		std::cin>>n;
		if(std::cin.eof())break;
		m=0,l=0;
		for(int i=2;i<=n;i++){
			for(int j=2;j<=i/2;j++){
				if(i%j==0)m++;
			}
			if(m==0)l++;
			m=0;
		}
		std::cout<<l<<std::endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int solve(int n){
    int ans=0,sum;
    for(int i=1;i<n+1;i++){
        sum=0;
        for(int j=1;j<i+1;j++){
            if(i%j==0)sum++;
        }
        if(sum==2)ans++;
    }
    return ans;
}
int main(void){
    int n;
    while(cin>>n){
        cout<<solve(n)<<endl;
    }
    return 0;
}

C++: 
#include<stdio.h>
int main()
{
    int a,N,M,sum=0,i,j,count=0,flag=0;
    while (scanf ("%d",&M)!=EOF )
        {
            for(i=2;i<=M;i++)
            {
                flag=0;

                if(i>2)
                {
                    for(j=2;j<i;j++)
                    {
                        if(i%j==0)
                        {
                            flag=1;
                            break;
                        }
                    }
                    if(flag==0)
                    {
                        count++;

                    }
                }

            }
                  printf("%d\n",count);
                  count=0;
        }

    return 0;
}

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

int main()
{
	bool is_prime[100000]:
	
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<1000000;i<i++){
		is_prime[i]=true;
	}
	
	for(int i=2;i*i<1000000;i++){
		if(is_prime[i]){
			for(int j=i*i;j<1000000;j+=i){
				is_primej]=false;
			}
		}
	}
	
	int n_prime[1000000];
	
	int cnt=0;
	for(int i=0;i<1000000;i++){
		if(is_prime[i]){
			cnt++;
		}
		
		n_prime[i]=cnt;
	}
	
	while(true){
		int n;
		cin>>n;
		if(cin.eof())
			break;
		
		cout<<n_prime[n]<<endl;
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAX_VALUE = 100007;
bool prime[MAX_VALUE];

int main() {
  vi primes;
  FOR(i, 2, MAX_VALUE){
    if(prime[i]) continue;
    primes.push_back(i);
    for(int j = i * 2; j<MAX_VALUE; j+=i)
      prime[j]=true;
  }

  int n;
  while(cin >> n) {
    REP(i, primes.size()){
      if(primes[i]-1 >= n) {
        cout << i << endl;
        break;
      }
    }
  }
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 999999

using namespace std;

typedef long long ll;

vector<int>primenumber;
int d[10500000];

int main()
{
	int n;
	
	primenumber.push_back(2);
	d[2] = 1;

	int maxn = 0;

	while (cin >> n) {
		if (maxn<n) {
			for (int i = max(maxn+1,3); i <= n; i++) {
				int ope = 1;
				for (int j = 0; j < primenumber.size(); j++) {
					if (primenumber[j] * primenumber[j] > i)break;
					if (i%primenumber[j] == 0) {
						ope = 0;
						break;
					}
				}
				if (ope == 1)primenumber.push_back(i);
				d[i] = primenumber.size();
			}
			maxn = n;
		}
		cout << d[n] << endl;
	}
	
	for (int i = 0; i < primenumber.size(); i++) {
		cout << primenumber[i] << endl;
	}

	return 0;
}

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

int main(){
  
  int n;

  while(cin >> n){
    bool Prime[1000000] = {};
    int i,j;
  
    for(i = 2; i <= sqrt(n) ; i++){
      if(Prime[i] == false){
        
	for(j = 2; i*j <= n ; j++){
	  Prime[i*j] = true;
	}
      }
    }
    int count = 0;
    for(i = 2 ; i <= n ; i++){
      if(Prime[i] == false){
	count++;
      }
    }
    cout << count << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
#include <ctype.h>
#include <cstdlib>
#include <string.h>
#include <cmath>
#include <cstdio>





using namespace std;

bool isPrime(int num);

int main()
{
	int count = 0;
	/*int m = 2, n = 0, num;

	cin >> num;

	int *data = new int[num + 1];
	int *result = new int[num + 1];

	data[0] = 0;
	data[1] = 0;

	do
	{
		for (i = 2 * m; i < num + 1; i += m)
		{

		}
	}
	while
	{

	}*/
	const int N = 9999999;
	int n;
	std::vector<bool> isPrime(N + 1, true);    // ?´???°????????°?????¨??¨ON???

	while (cin >> n)
	{
		count = 0;
		for (int i = 2; i <= n; ++i) {
			if (isPrime[i])
			{
				count++;

				for (int k = i + i; k <= n; k += i)
					isPrime[k] = false;      // ?´???°????????°????´???°????????°?????¨???OFF???
			}
		}

		cout << count << endl;
	}
	
	return 0;






	
}

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

int main(){
	bool b[1000000] = {};
	for(int i = 2; i < 1000000; i++){
		b[i] = true;
	}
	for(int i = 2; i < 1000; i++){
		if(b[i]){
			for(int j = i * i; j < 1000000; j += i){
				b[j] = false;
			}
		}
	}

	int n, count = 0;
	cin >> n;
	for(int i = 0; i <= n; i++){
		if(b[i]){
			count ++;
		}
	}
	cout << count << endl;
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int i=0,j=0;
	int n=0;
	int count=0;
	int kioku[200000]={0};
	int flg=0;
	while (scanf("%d",&n)!=EOF)
	{
		count=0;
		if (n>=2)
		{
			kioku[0]=2;
			count++;
		}
		for (i=3;i<=n;i+=2)
		{
			for (j=0;j<count;j++)
			{
				if (i%kioku[j]==0)
				{
					flg=1;
					break;
				}
			}
			if (flg==1)
			{
				flg=0;
			}
			else
			{
				kioku[count]=i;
				count++;
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

C++: #include<stdio.h>



int main(){
	int n,i,j;
	bool c[1000];
	int data[1000];
	int count;
	int premaxin=1;


	for(i=0;i<1000;i++){
		c[i]=1;
		data[i]=0;
	}
	c[0]=c[1]=0;

	while(scanf("%d",&n)!=EOF){

		if(premaxin<n){
			for(i=0;i<=n;i++){
				if(c[i]==1){
					if(premaxin>i){
						j=premaxin;
					}else{
						j=i+1;
					}
					for(;j<=n;j++){
						if(j%i==0){
							c[j]=0;
						}
					}
				}
			}

			count=data[premaxin];
			for(i=premaxin+1;i<=n;i++){

				if(c[i]==1){
					count++;
				}
				data[i]=count;
			}
		}

		printf("%d\n",data[n]);
	}
	return 0;
}