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"stdio.h"
#include"string.h"
using namespace std;
long kt( string a)
{
	long d=0, d1=0;
	long n=a.size();
	if(97<=a[0]&&a[0]<=122)
	{
			for(long i=1;i<n;i++)
			if(65<=a[i]&&a[i]<=90)
			d++;
	}
	
	for(long i=0;i<n;i++)
	{
		if(65<=a[i]&&a[i]<=90)
		d1++;
	}
	if(d1==n) return 2;
	if(d==n-1) return 1;
	return 0;
}
long main()
{
	
	string a;
	cin>>a;
	long n=a.size();
	if(kt(a)==2)
	{
		for(long i=0;i<n;i++)
		a[i]+=32;
		cout<<a;
		return 0;
	}
	if(kt(a)==1)
	{
		for(long i=1;i<n;i++)
		a[i]+=32;
		a[0]-=32;
		cout<<a;
		return 0;
	}
	else cout<<a;
}
*/

#include <iostream>
using namespace std;

#define long long long
const long N = 1000000;
bool np[N];
long p[N], pp=0;

void eratos() {
    np[0]=np[1]=true;
    for (long i=2; i*i<N; i++) if (!np[i])
        for (long j=i*i; j<N; j+=i) np[j]=true;
}
main()
{
	eratos();
	long n,d=0;
do
{
     d=0;
	cin>>n;
	
	for(long i=1;i<=n;i++)
	if(np[i]==false)
	d++;
	cout<<d<<endl; 

}while(1);
}

C++: #include <iostream>
using namespace std;
bool prime[1000000];
void sieve() {
    fill_n(prime, 1000000, true);
    for (int i=2; i<=1000 && prime[i]; ++i) {
        for (int j=i*i; j<1000000; j+=i) {
            prime[j] = false;
        }
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    sieve();
    int n;
    while (cin >> n) {
        int cnt = 0;
        for (int i=2; i<=n; ++i) {
            if (prime[i]) {
                cnt ++;
            }
        }
        cout << cnt << "\n";
    }
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <math.h>

using namespace std; 

int list[1000000]={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73,
79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163,
 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251,
 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443,
 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557,
 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647,
 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757,
 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863,
 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983,
 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069};

long int a,b,loop,hasil,input,mid;
long int lo;
long int hi;

 bool Prima(unsigned long n) 
{
    for (unsigned short i = 0; list[i]*list[i] <= n; i++) 
	{
        if (n % list[i] == 0) 
		{
            return false;
        }
    }
 
    return true;
}

int main()
{
	lo=1087;
	a=180;
	while(lo<=100003)
	{
		if(Prima(lo))
		{
			list[a]=lo;
			a++;
		}
		lo+=2;
	}
	//printf("%d",list[78498]);
	while(scanf("%ld",&input)!= EOF)
	{	
	lo=0;
	while(input>=list[lo])
	{
		lo++;
	}
	printf("%d\n",lo);
	}
	return 0; 
}

C++: #include <stdio.h>

int IsPrime(int n);

int main(void){
    int n, cnt, minID, min=1;
    int max[30], sol[30], listID=0;
	
    while (scanf("%d", &n) && n!=EOF){
        cnt=0;
        min = 1;
        minID = 0;
        for (int i=0; i<listID; i++){
            if (max[i] < n && min <max[i]){
                min = max[i];
				cnt = sol[i];
            }
        }
        for (int i=min+1; i<=n; i++){
            if (IsPrime(i)) cnt++;
        }
        max[listID] = n;
        sol[listID] = cnt;
        listID++;
        printf("%d\n", cnt);
    }
    return 0;
}

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

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

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;
const static int	de_MIN = -999999999;

bool Judge_PrimeNumber(const int a) {

	if (a < 2) { return false; }
	if (a == 2) { return true; }
	if (a % 2 == 0) { return false; }

	for (int i = 3; i <= a / i; i += 2) {
		if (a%i == 0) {
			return false;
		}
	}
	return true;
}

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());

	int n = 0, ans = 0;
	std::vector<int> A;

	while (std::cin >> n) {
		A.push_back(n);
	}

	for (unsigned int i = 0; i < A.size(); i++) {
		ans = 0;
		for (int j = 2; j <= A[i]; j++) {
			if (Judge_PrimeNumber(j)) {
				ans++;
			}
		}
		std::cout << ans << std::endl;
	}

}

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

int main(){

	const int N_MAX=100000;
	int i,j,n[32],ni,soi,max;
	int so[N_MAX],count[N_MAX];
	
	for(i=0;i<N_MAX;i++)
		count[i]=so[i]=0;
	ni=0;
	max=0;
	while(cin>>n[ni])
		if(n[ni++]>max)
			max=n[ni-1];
	int sq_max = (int)sqrt(max);
	so[0]=so[1]=1;
	for(soi=0,i=2;i<=sq_max;i++){
		if(so[i]>0)continue;
		for(j=i*2;j<=max;j+=i)
			so[j]=1;
	}
	for(i=2;i<=max;i++){
		count[i] = count[i-1]+1-so[i];
	}
	for(i=0;i<ni;i++)
		cout << count[n[i]] << endl;

	return 0;
}

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

void count_Prime(int n);
int Euclid(int n, int m);

int main()
{
	int Data;

	while (cin >> Data)
	{
		count_Prime(Data);
	}

	return 0;
}

void count_Prime(int n)
{
	int counter = 0;
	for (int i = 2; i <= n; i++)
	{
		for (int j = 2; j <= i; j++)
		{
			int euclid = Euclid(j, i);
			// ?????§??¬?´???°???1(??????????´?)?????????????????¨????????¨??????
			if (euclid == i)
				counter++;     // ????????????????????§??????
			else if ( euclid != 1)               // ?????????????????¨??????Break????¨????????????\
				break;
		}
	}

	cout << counter << endl;

}

int Euclid(int n, int m)
{
	if (m % n == 0)
	{
		return n;
	}
	else
	{
		return Euclid(m%n, n);
	}
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
	vector<int> array;
	int n;
	bool f;
	cin >> n;
	for(int i=2;i<=n;i++){
		f=true;
		for(int j=0;j<array.size();j++)
		if(!(i%array[j])){
		f=false;
		continue;
	}
		if(f==true)array.push_back(i);
	}
	cout << array.size() << endl;
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
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(scanf("%d", &n) != EOF){
		count = 0;
		for(i = 1; i <= n; i++){
			if(is_prime(i) == 1 && i != 1) count ++;
		}
		cout << count << endl;
	}

	return 0;
}