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 <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

vector<int> prime;
bool is_prime[1000010];
int sieve(int n) {
  fill(is_prime + 2, is_prime + 1000010, true);
  for (int i = 2; i <= n; i++) {
    if (is_prime[i]) {
      prime.emplace_back(i);
      for (int j = 2 * i; j <= n; j += i) is_prime[j] = false;
    }
  }
  return prime.size();
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  sieve(1000000);
  int n;
  while (cin >> n) {
    cout << upper_bound(prime.begin(), prime.end(), n) - prime.begin() << endl;
  }

  return 0;
}

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

int primes[78498], primepis[1000000], num_primes;
int calculated;
int main() {
	primes[0] = 2;
	primepis[2] = 1;
	calculated = 2;
	num_primes = 1;
	for (int i = 3; i <= 999999; i += 2) {
		bool is_prime = true;
		int max = (int)(sqrt(i)) + 1;
		for (int j=1; primes[j] < max && j<num_primes; j++) {
			if (i%primes[j] == 0) {
				is_prime = false;
				break;
			}
		}
		if (is_prime) {
			primes[num_primes++] = i;
			primepis[i] = primepis[i + 1] = primepis[i - 1] + 1;
		}
		else {
			primepis[i] = primepis[i + 1] = primepis[i - 1];
		}
	}
	while (true) {
		int n;
		if (!scanf("%d", &n)) break;
		printf("%d\n", primepis[n]);
	}
}

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

using namespace std;

bool isprime(int N)
{
	for (int I = 2; I <= sqrt(N); I++)
	{
		if (N % I == 0) return false;
	}

	return true;
}

int main()
{
	int n;

	int c = 0;

	cin >> n;

	for (int i = 2; i <= n; i++)
	{
		if (isprime(i) == true)
		{
			c += 1;
		}
	}

	cout << c << endl;

	return 0;
}

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

using namespace std;

vector<int> Prime;
void PrimeCalc()
{
	bool IsPrime[1000000];
	for(int i = 0; i < 1000000; ++i)
	{
		IsPrime[i] = true;
	}
	IsPrime[0] = IsPrime[1] = false;
	for(int i = 2; i < 1000000; ++i)
	{
		if(IsPrime[i])
		{
			Prime.push_back(i);
			for(int j = 2 * i; j < 1000000; j += i)
			{
				IsPrime[j] = false;
			}
		}
	}
}

void solve()
{
	PrimeCalc();
	int n;
	while(cin >> n)
	{
		int ans = 0;
		int pos = 0;
		for(int i = 0; i < Prime.size(); ++i)
		{
			if(Prime[i] <= n)
			{
				++ans;
			}
			else
			{
				break;
			}
		}
		cout << ans << endl;
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;


int main(){
    int n, ans, cnt, prime;

    while(cin >> n){
      prime = 1;
      for(int i=3; i <= n; i++){
        cnt = 0;
        for(int j=2; j<i; j++){
          if(i%j==0) cnt++;
        }
        if(cnt==0) prime++;
      }
      cout << prime << endl;
    }
    return 0;
}

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

int Era(int N) {
	int prime_num = 0;
	int* array = new int[N + 1];
	for (int i = 2; i < N + 1; i++) {
		array[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (array[i]) {
			for (int j = 0; i*(j + 2) <= N; j++) {
				array[i*(j + 2)] = 0;
			}
		}
	}
	for (int i = 2; i < N + 1; i++) {
		if (array[i])prime_num++;
	}
	return prime_num;
}

void add(int* primes, int& now,int prime) {
	primes[now] = prime;
	now++;
}

int main() {
	int num;
	int primes[1000]; int now = 0;
	while (cin >> num) {
		add(primes, now, Era(num));
	}
	for (int i = 0; i < now; i++) {
		cout << primes[i] << endl;
	}
	return 0;
}

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


using namespace std;
#define MAX_NUM 999999


int do_count(bool *isPrime, int n);

int main(){
  int n;
  //?´???°???true,
  bool flag = false;
  bool isPrime[MAX_NUM];


  int pivot = 2;
  
  for(int i=0;i<MAX_NUM;i++){
    isPrime[i] = false;
  }
  
  while(cin >> n){
    int cnt=0;
    //cout << n << endl;
    //    sqrt_n = sqrt(n);
    for(int i=2;i<=n;i++){
      flag = false;
      //?´???°?????????????????§??????
      for(int j=pivot;j<=sqrt(i);j++){
	if(i%j==0){
	  flag = true;
	  break;
	}
      }
      if(flag){continue;}
      isPrime[i]=true;
      //cout << "last: " << i << endl;
    }
    cnt = do_count(isPrime, n);
    //cout << "cnt: " << cnt << endl;
    cout << cnt << endl;
  }
}

int do_count(bool *isPrime, int n){
  int cnt=0;
  for(int i=0;i<=n;i++){
    if(isPrime[i]==true){
      cnt++;
    }
  }
  return cnt;
}

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

bool sieve[1000000];

int main() {
	int n;

	sieve[0] = true;
	sieve[1] = true;

	while (std::cin >> n) {
		if (n <= 1) {
			std::cout << 0 << std::endl;
			continue;
		}

		for (int i = 2; i*i <= n; ++i) {
			if (!sieve[i]) {
				for (int j = i + i; j <= n; j += i)
					sieve[j] = true;
			}
		}

		std::cout << std::count(sieve, sieve + n + 1, false) << std::endl;
	}
}

C++: j,a['   '],s;main(i){for(;++i<1e6||~scanf("%d",&j)&&printf("%d\n",a[j]);)for(s+=!a[j=i];j<1e6;a[i]=s)a[j+=i]=1;}

C++: #include<iostream>
using namespace std;
int main(){
  bool num[1000000] = {false};
  for(int i=2; i<1000; i++){
    if(!num[i]){
      for(int j=i*i; j<1000000; j+=i){
	num[j] = true;
      }
    }
  }
  int n;
  while(cin >>n){
    int sum = 0;
    for(int i=2; i<=n; i++){
      if(!num[i]){sum++;}
    }
    cout <<sum<<endl;
  }
  return 0;
}

C++: #include<iostream>

using namespace std;
int prime[1000000];

int main(){
	
    prime[0]=-1;
    prime[1]=-1;
    
    for(int i=2;i<1000000;i++){ 
    
        if( prime[i] == 0 ){
        	
            prime[i] = 1;
            for(int j=i*2;j<1000000;j+=i)
			prime[j] = -1 ;
			
        }
        
    }
    int a;
    while( cin >> a ){
    	
        int count = 0;
        
        for(int i=1;i<a+1;i++)
		if(prime[i] == 1)
		count++;
		
        cout << count << "\n";
    }
    return 0;
}

C++: #include<iostream>
#include<stdio.h>
using namespace std;
 
int main(){
int n;
 
 
while(cin >> n){
int count =0;
for(int i=2;i<=n;i++){
        for(int j=2;j<=i;j++){
                if(i%j==0 && j != i)    break;
                if(j==i)        count++;
                
                }
        }
 
cout << count << endl;  
 }
return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	long long int N,count[1000000];
		count[1] = 1;
		if(N<0)	break;
	for(int x=2;x<=1000000;x++){
		int flag = 0;
		for(int y=2;y<x;y++){
			if((x%y)==0)	flag = 1;
		}
		if(flag == 0)	count[i] = count[i-1]+1;
	}
	while(cin >> N){
		cout << count[N] << endl;
	}
	return 0;
}

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

int a[1000000];

int main()
{
  int n;
  int count;

  for (int i = 2; i < 1000000; i++){
    a[i] = 1;
  }

  for (int i = 0; i * i < 1000000; i++){
    if  (a[i] == 1){
      for (int j = 2; j * i <= 100000; j++){
        a[j * i] = 0;
      }
    }
  }

  while (cin >> n){
    count = 0;
    for (int i = 0; i < 1000000; i++){
      if (a[i] == 1){
        count++;
      }
    }
  }

  cout << count << endl;

  return (1);
}