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>
#include<cmath>
using namespace std;

int main(){
	int cnt, x, n, i, j;
	bool flg;
	double rootx;
	int rootintx;
	while(cin>>n){
		cnt=0;
		if(n>=2)cnt++;
		for(x=3;x<=n;x+=2){
			flg = true;
			if(x==2){
				cnt++;
				continue;
			}
			if(x<2 || !(x%2)){
				continue;
			}
			rootx = sqrt(x);
			rootx = ceil(rootx);
			rootintx = int(rootx);
			for(j=2;j<=rootintx;j++){
				if(!(x%j)){
					flg=false;
					break;
				}
			}
			if(flg)cnt++;
		}
		cout<<cnt<<endl;;
	}
	return 0;
}

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

using namespace std;

int main(void){
	int num = 0;
	vector<int> vec;
	while (cin >> num){
		int count = 0;
		bool hantei = true;
		for (int i=2; i<num; ++i){
			for (int j=2; j<i; ++j){
				if ((i%j) == 0){
					hantei = false;
					break;
				}
			}
			if (hantei == true){
				++count;
			}
		}
		vec.push_back(count);
	}
	vector<int>::iterator it = vec.begin();
	while(it != vec.end()){
		cout << *it << endl;
		++it;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;


int main(){
	int n=0,m=0,o=0,f=0,c=0;

	while(cin>>n){
		c=0;

	for(o=2;o<=n;o++)
	{	f=0;
		for(m=2;m<o/2;m++){
			if(o%m == 0){f++;}

		};
		if(f==0){c++;};

	};
	cout<<c<<endl;
	};
 return 0;

}

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

using namespace std;

int main() {
	int n;

	while (cin >> n) {
		int counter = 1;
		
		if(n < 1000){
			for (int i = 3; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		}else if(n < 10000){
			counter = 168;
			for (int i = 1001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 100000){
			counter = 1229;
			for (int i = 10001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 200000){
			counter = 9592;
			for (int i = 100001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 300000){
			counter = 17984;
			for (int i = 200001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 400000){
			counter = 25997;
			for (int i = 300001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 500000){
			counter = 33860;
			for (int i = 400001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 600000){
			counter = 41538;
			for (int i = 500001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 700000){
			counter = 49098;
			for (int i = 600001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 800000){
			counter = 56543;
			for (int i = 700001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if(n < 900000){
			counter = 63951;
			for (int i = 800001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else if (n < 999999){
			counter = 71274;
			for (int i = 900001; i <= n; i=i+2) {
				int kari = 1;
				for (int j = 3; j < i; j=j+2) {
					kari = i % j;
					if(kari == 0) {
						break;
					}
				} if (kari != 0) {
					counter++;
				}
			}
		} else {
			counter = 78498;
		}
		cout << counter << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int shusu[35];
	int d=0;
	for(int i=2;;i++)
	{
		int bj=1;
		for(int j=2;j<=sqrt(i);j++)
		{
			if(i%j==0)
			{
				bj=0;
				break;
			}
		}
		if(bj==1)
		{
			shusu[d++]=i;
		}
		if(d==35)
		{
			break;
		}
	}
	int n;
	while(cin>>n)
	{
		for(int i=0;i<35;i++)
		{
			if(n<2)
			{
				cout<<0<<endl;
				break;
			}
			if(n>=shusu[i] && n<shusu[i+1])
			{
				cout<<i+1<<endl;
				break;
			}
		}
	} 
	return 0;
}

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

void AOJ0009()
{
	int n = 0;
	int prime[1000];
	int count = 0;
	for (int i = 2; i <= 1000; i++)
	{
		int j = 2;
		bool flag = false;
		for (j = 2; j <= i; j++)
		{
			if (i % j == 0)
				break;
		}
		if (i == j)
		{
			prime[count] = i;
			count++;
		}
	}

	while (cin >> n)
	{
		count = 0;
		while (prime[count] <= n)
		{
			count++;
		}
		cout << count << endl;
	}
}
int main()
{
	//AOJ0005();
	//AOJ0007();
	AOJ0009();
	return 0;
}

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

int main() {
	int n;

	while (cin >> n) {
		int count = 0;
		bool table[1000001] = { false };
		int upper = sqrt(n);

		table[1] = true;

		for (int i = 1; i <= upper; i++) {
			if (table[i] == false) {
				table[i] = true;
				count++;
				for (int j = i; j <= n; j += i) {
					table[j] = true;
				}
			}
		}

		for (int i = upper; i <= n; i++) {
			if (table[i] == false) {
				count++;
			}
		}

		cout << count << '\n';
	}

	return 0;
}