Go: package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = i
        }

        Soe()

        for i := 0; i < MAX; i++ {
                primes[i] %= 2
        }
        primes[1] = 0
        primes[2] = 1
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := 2; j < MAX/i; j++ {
                                if i * j < MAX {
                                        primes[i*j] = 0
                                }
                        }
                }
        }
}

C++: /// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009
/// http://www.tsg.ne.jp/TT/tsg/c/mansaku/P01.html
#include<cstdio>
#include<cmath>

int main(){
    int n, cnt=0;
    scanf("%d", &n);
    for(int i = 3; i<=n; i+=2){
        int k= 0;
        for(int j=3; j<sqrt(i); j+=2){
            if(i%j==0){
                k=1;
                break;
            }
        }
        if(k==0) cnt++;
    }
    printf("%d\n", cnt);

    return 0;
}

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

bool isprime(int x){
	if(x==2) return true;
	if(x<2 && !(x%2)) return false;
	x = int(ceil(sqrt(x)));
	for(int i=3;i<=x;i+=2){
		if(!(x%i)) return false;
	}
	return true;
}

int main(){
	int x,i,cnt;
	while(cin>>x){
		cnt=0;
		for(i=2;i<=x;i++){
			if(isprime(i)) cnt++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<windows.h>
#include<conio.h>
#include<String>
#include<time.h>
#include<math.h>

using namespace std;
int c = 0;
int i = 1;
unsigned long long a = 0;
unsigned long long b = 0;
unsigned long long sosuu[100000] = { 0 };
char fire = 0;
int pattara = 0;

int sub(int c) {

	
	
	
	for (int i = 2; i<=c; i++){
		
		for (int q = 1; q <= sqrt(i); q++) {
			sosuu[pattara] = i;
			if (sosuu[pattara] % 2 == 0 && sosuu[pattara]!= 2) {
				break;
			}
			if (sosuu[pattara] % q == 0) {
				b += 1;
			}

		}

		if (b == 1) {
			
			pattara++;
			
		}
		b = 0;
		
	}

	
	return 0;
}


int main(){
	while (scanf("%d", &c) != EOF){

		sub(c);
		cout << pattara << endl;
		pattara = 0;
		
	}

	return 0;
}

C++: #include<iostream>
#define Max 1000000   

bool prime[Max];  
void IsPrime(){  
     prime[0]=prime[1]=0;prime[2]=1;  
     for(int i=3;i<Max;i++)  
        prime[i]=i%2==0?0:1;  
     int t=(int)sqrt(Max*1.0);  
     for(int i=3;i<=t;i++)  
       if(prime[i])  
         for(int j=i*i;j<Max;j+=2*i)//?化    
            prime[j]=0;  
}

int main(){
	int n;
	IsPrime();
	int time=0;
	while((time<=30)&&(std::cin>>n)){
		int count=0;
		for(int i=2;i<=n;++i){
			if(prime[i]) 
				++count;
		}
		std::cout<<count<<std::endl;
		time++;
	}
}

C++: #include<bits//stdc++.h>
using namespace std;
int main(){
	 vector<int> a(100);
	a[0]=2;
	int z=1;
	for(int i=2;i<100000;){
		for(int j=0;j<z;j++){
			if(i%a[j]==0)goto stop;
		}
		a[z]=i;
		z++;
		stop:;
		if(i==2) i++;
		else i+=2;
	}
	int b;
	while(cin>>b){
		int c=0;
		for(int i=0;i<z;i++){
			if(a[i]>b)break;
			else c++;
		}
		cout<<c;
	}
}

C++: #include <iostream>

using namespace std;

int main(){
  int n,visited,cnt=0;
  
  while(cnt<30){
    int count =0;
    cnt++;
    cin >> n;
    if(n==0)count =0;
    for(int j=2;j<=n;j++){
      visited=0;
      for(int i = 2;i<=n;i++){
	
	if(j%i==0&&j!=i)visited=1;
	else if(j%i==0&&j==i&&visited==0)count++;
	
      }
    }
    cout << count << endl;
  }
  return 0;
}

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

using namespace std;
int sieve(int n);
int prime[1000000];
bool is_prime[1000000];

int main()
{

	int p = 0;
	for (int i = 0; i <= 999999; i++) {
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= 999999; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = 2 * i; j <= 999999; j += i) {
				is_prime[j] = false;
			}
		}
	}
	while (true) {
		int n;
		cin >> n;
		int i = 0;
		while (prime[i] <= n) {
			i++;
		}
		cout << i << endl;
	}
}

C++: #include <iostream>  
#include <stdio.h>  
#include <math.h>  
#include <string.h>  
  
using namespace std;  
  
const int N = 1e6;  
const int SQRTN = ceil(sqrt((double) N));  
bool isPrime[N];  
int prefixsum[N];  
  
// Eratosthenes筛选法  
void esieve(void)  
{  
    memset(isPrime, true, sizeof(isPrime));  
  
    isPrime[0] = isPrime[1] = false;  
    for(int i=2; i<=SQRTN; i++) {  
        if(isPrime[i]) {  
            for(int j=i*i; j<=N; j+=i)  //筛选  
                isPrime[j] = false;  
        }  
    }  
}  
  
void maketable()  
{  
    prefixsum[0] = 0;  
    for(int i = 1; i <= N; i++)  
        prefixsum[i] = isPrime[i] ? prefixsum[i - 1] + 1 : prefixsum[i - 1];  
}  
  
int main()  
{  
    esieve();  
  
    maketable();  
  
    int n;  
    while(~scanf("%d", &n))  
        printf("%d\n", prefixsum[n]);  
  
    return 0;  
}

C++: #include <stdio.h>
 
#define MN 
 
int main(void)
{
    int n;
    int i, j;
	long LN = 1000001;
    int pn[1000001];
     
    for (i = 0; i < LN; i++){
        pn[i] = 1;
    }
     
    pn[0] = pn[1] = 0;
     
    for (i = 2; i * i < LN; i++){
        if (pn[i] == 1){
            for (j = i * i; j < LN; j += i){
                pn[j] = 0;
            }
        }
    }
     
    for (i = 1; i < LN - 1; i++){
        pn[i + 1] += pn[i];
    }
     
    while (cin >> n){
    	cout << pn[n] << endl;
    }
     
    return (0);
}

C++: #pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>

using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rer(i,l,r) for(int(i)=(l); (i)<(r); ++(i))
#define rep(i,n) rer(i,0,n)
#define gnr(i,l,r) for(int (i)=(r)-1; (i)>=(l); --(i))
#define pri(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<(p).fi<<' '<<(p).se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

int main(){
  cin.tie(nullptr); ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);

  auto pri=prime_table(1000000);
  V(int)psum(1000000,0);
  rer(i,1,1000000){
    psum[i]=psum[i-1]+pri[i];
  }
  while(cin>>n)pri(psum[n]);
}

C++: #include <cstdio>

using namespace std;

int n;
int euler(int n){
     int res=n,a=n;
     for(int i=2;i*i<=a;i++){
         if(a%i==0){
             res=res/i*(i-1);
             while(a%i==0) a/=i;
         }
     }
     if(a>1) res=res/a*(a-1);
     return res;
}
int main()
{
    while(scanf("%d",&n)==1)
    printf("%d\n",n);
    return 0;
}