Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	a, _ := strconv.Atoi(scanner.Text())
	return a
}

func isPrime(n int) bool {
	for i := 2; i*i <= n; i++ {
		if n % i == 0 {
			return false
		}
	}
	return true
}

func main() {
	for scanner.Scan() {
		n := nextInt()
		cnt := 0
		for i := 2; i <= n; i++ {
			if isPrime(i) {
				cnt++
			}
		}
		fmt.Println(cnt)
	}
}

C++: #include<stdio.h>
#define MAX 1000//1000010

int main(){
	bool prime[MAX];
	prime[0]=prime[1]=0;
	for(int i=0;i<MAX;i++){
		prime[i]=1;
	}
	prime[0]=prime[1]=0;
	for(int i=2;i<MAX;i++){
		if(prime[i]==1){
			for(int j=2;i*j<MAX;j++){
				prime[i*j]=0;
			}
		}
	}
	int prime_under_num[MAX];
	prime_under_num[0]=0;
	for(int i=1;i<MAX;i++){
		prime_under_num[i]=prime_under_num[i-1]+prime[i];
	}
	
	int n;
	while((scanf("%d",&n))!=EOF){
		printf("%d\n",prime_under_num[n]);
	}
	
	
}

C++: #include<iostream>
using namespace std;
int main(){
int a,i;
cin>>a;
for(int x=0;x<a;x++){
if(a%x){i++}
cout<<i<<endl;
}
return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair

vector<ll> getPrimesFast(ll n){
    vector<ll> primes;
    if (n < 10000){
        primes.clear();
        if (n < 2){
            return primes;
        }
        primes.push_back(2);
        if (n == 2){
            return primes;
        }
        primes.push_back(3);
        if (n == 3){
            return primes;
        }
        for(ll i = 5; i <= n; i += 2){
            bool isPrime = true;
            for(int p = 0; p < (int)primes.size(); ++p){
                if (i % primes[p] == 0){
                    isPrime = false;
                    break;
                }
            }
            if (isPrime) {
                primes.push_back(i);
            }
        }
        return primes;
    }
    else{
        vector<ll> sieve = getPrimesFast(sqrt(n));
    
        vector<short> isPrime(n+1, 1);
        for(int i = 0; i < (int)sieve.size(); ++i){
            for(int j = sieve[i] * 2; j <= n; j += sieve[i]){
                isPrime[j] = 0;
            }
        }

        for(int i = 2; i <= n; ++i){
            if (isPrime[i]){
                primes.push_back(i);
            }
        }
        return primes;
    }
}

int main(void)
{
    cin.sync_with_stdio(false);
    int n;

    auto primes = getPrimesFast(1000000);

    while(cin >> n) {
        auto itr = upper_bound(ALL(primes), n);
        cout << itr - primes.begin() << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
	int n,k=0;
	vector<int> pri(1000000);
	for(int i=0;i<1000000;i++)
		pri[i]=1;
	pri[0]=0;
	pri[1]=0;
	for(int i=0;i*i<n;i++){
		if(pri[i]){
			for(int j=i*2;j<1000000;j+=i)
				pri[j]=0;
		}
	}
	cin>>n;
	int i=0;
	while(k<=n)
	if(pri[k++])
	i++;
	cout<<i<<endl;
	
	
	
	return 0;
}

C++: #include <cstdio>
#define SIZE 1000001

int main(void)
{
  int i, j, k, n;
  int memo[SIZE] = {};

  memo[0] = 1;
  memo[1] = 1;
  for (i = 2; i <= SIZE; i++) {
    if (memo[i] == 0) {
      for (j = i * 2; j <= SIZE; j = j + i) {
        memo[j] = 1;
      }
    }
  }
  
  while (scanf("%d", &n) != EOF) {
    k = 0;
    for (i = n; i > 0; i--) {
      if (memo[i] == 0) k++;
    }
    std::printf("%d\n", k);
  }
}

C++: #include <iostream>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;





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





}

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

#define N 1000000

using namespace std;

int main(void){
	bool prm[N];
	for(int i=0;i<N;i++)prm[i]=true;
	int upto = (int)sqrt(N);
	for(int i=2;i<=upto;i++){
		if(prm[i]){//消されてなければその倍数を消す
			for(int j=2;i*j<=N;j++) prm[i*j] = false;
		}
	}
	int n;
	while(cin >> n){
		int count = 0;
		for(int i=2;i<=n;i++){
			if(prm[i]) count++;
		}
		cout << count << "\n";
	}
	return 0;
}

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

#define MAX 1000000

int prime[MAX]={};

void eratos(void){
	int i,j;
	prime[0] = 1;
	prime[1] = 1;
	for(i = 2;i < MAX/2;i++){
		for(j = 2;i*j <= MAX;j++){
			prime[i*j] = 1;
		}
	}
}

int main(void){
	long i,j;
	long n;
	int cnt;
	int prime_cnt;

	eratos();
	while(scanf("%ld",&n) != EOF){
		prime_cnt = 0;
		for(i = 0;i <= n;i++){
			if(prime[i] == 0)
				prime_cnt++;
		}
		/*prime_cnt = 0;
		for(i = 0;i < n+1;i++){
			cnt = 0;
			if(i < 2) continue;
			if(i == 2){
				prime_cnt++;
				continue;
			}
			for(j = 2;j <= i/2;j++){
				if(i % j == 0){
					cnt++;
					break;
				}
			}
			if(cnt == 0) prime_cnt++;
		}
		printf("%d\n",prime_cnt);*/		
		printf("%d\n",prime_cnt);
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;


int sum[1000010];
void init(){
    for(int i = 2 ; i <= 1000000 ; i++){
        sum[i] = sum[i-1] + 1;
        for(int j = 2 ; j*j <= i ; j++){
            if( i % j == 0 ){
                sum[i]--;
                break;
            }
        }
    }
}
int main() {
    init();
    int n;
    while( cin >> n && n ){
        cout << sum[n] << endl;
    }
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n;
  while(cin >> n){
    int cnt=0,res=0;
    for(int i=3; i<=n; i+=2){
      for(int j=1; j<=i; j++){
        if(i%j == 0) cnt++;
      }
      if(cnt==2) res++;
      cnt = 0;
    }
    cout << res+1 << endl;
  }
  return 0;
}

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

int eratos(forward_list<int> xs) {
	if (xs.empty()) return 0;
	int head = xs.front();
	xs.pop_front();
	xs.remove_if([&](int n){
		    return !(n%head);
		    });
	return 1+eratos(xs);
}

int main() {
	int n;
	while (cin>>n) {
		forward_list<int> ls(n-1);
		iota(begin(ls),end(ls),2);
		cout << eratos(ls) << endl;
	}
	return 0;
}

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

int main(){

	const int N_MAX=1000000;
	int i,j,n[32],ni,max;
	int count[N_MAX];
	bool so[N_MAX];
	
	for(i=0;i<N_MAX;i++)
		so[i]=true;
	ni=0;
	max=0;
	while(cin>>n[ni])
		if(n[ni++]>max)
			max=n[ni-1];
	so[0]=so[1]=false;
	for(j=4;j<=max;j+=2)
			so[j]=false;
	for(i=3;i<=1000;i+=2){
		if(so[i]==0)continue;
		for(j=i*2;j<=max;j+=i)
			so[j]=false;
	}
	for(i=2;i<=max;i++){
		count[i] = count[i-1]+so[i];
	}
	for(i=0;i<ni;i++)
		cout << count[n[i]] << endl;

	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <algorithm>
#include <stack>
#include <string>

using namespace std;


int main(){
	int n = 0;
	int count;
	bool flag = false;
	while(cin >> n){
		count = 0;
		for(int i = 2; i <= n; i++){
			if(i == 2){
				count++;
			}
			else if(i % 2 != 0){
				for(int j = 3; j * j <= i; j += 2){
					if(i % j == 0){
						flag = true;
						break;
					}
				}
				if(flag != true){
					count++;
				}
				flag = false;
			}
		}

		cout << count << endl;

	}

	return 0;
}