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] = 1
        }
        primes[0] = 0
        primes[1] = 0
        Soe()
}

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

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

using namespace std;

int main() {

	int n,count;

	while (cin >> n) {
		
		//?´???°????????????????????§?????????
		bool is_prime;

		//2????´???°??????????????????????????????
		count = 1;

		//i??¨????????°????´???°????????????
		for (int i = 3; i <= n; i+=2) {
			cout << "i=" << i << endl;
			is_prime = true;
			//????????°??????????°?????????°??§?????£?????????
			for (int j = 3; j <= sqrt(n); j+=2) {
				if (i == j) {
					break;
				}
				cout << "i=" << i << " j=" << j << " i%j=" << i%j << endl;
				if (i%j == 0) {						//????????????????????????????´???°??§?????????
					is_prime = false;
					break;
				}
			}
			//?????????????????°???????????£???????????°i????´???°
			if (is_prime==true) {
				cout << i << " is prime" << endl;
				count++;
			}
		}

		//??¨???
		cout << count << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
	int numa[4];
	int numb[4];
	int a, i, j;
	int hit, blow;
	

	while((cin.get()) != istream::traits_type::eof())
	{	
		for(i = 0; i < 4; i++)
		{
			cin >> numa[i];
		}
		
		for(i = 0; i < 4; i++)
		{
			cin >> numb[i];
		}
		
		
		hit = 0;
		
		for(i = 0; i < 4; i++)
		{
			if(numa[i] == numb[i])
			{
				hit = hit + 1;
			}
		}
		
		blow = 0;
		for(i = 0; i < 4; i++)
		{
			for(j = 0; j < 4; j++)
			{
				if(numa[i] == numb[j] && i != j)
				{
					blow = blow + 1;
				}
			}
		}
		
		cout << hit << " " << blow << endl;
	}
		
	return 0;
		
}

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

using namespace std;

int main(){
	int n,i,j,buf,cnt;

	while(cin >> n){
		cnt = 1;

		for(i=3;i<=n;i+=2){
			buf = (int)sqrt((double)i);

			for(j=3;j<=buf;j+=2){
				if((i % j) == 0){
					cnt--;
					break;
				}
			}

			cnt++;
		}

		cout << cnt << endl;
	}

	return 0;
}

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

int main() {
	static bool Prime[1000000] = {};
	static int Count[1000000] = {};
	for (int i = 2; i < 1000000; i++) {
		Prime[i] = true;
	}
	for (int i = 2; i <= 1000; i++) {
		if (Prime[i]) {
			for (int j = 2; j <= 999999 / i; j++) {
				Prime[i * j] = false;
			}
		}
	}
	for (int i = 2; i < 1000000; i++) {
		Count[i] = Count[i - 1];
		if (Prime[i]) Count[i]++;
	}
	int N;
	while (cin >> N) {
		cout << Count[N] << endl;
	}
}

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

int prime(int data){
	int i;
	if(data == 2){
		return 1;
	}
	if(data%2 == 0){
		return 0;
	}
	for(i = 2;i < data;i++){
		if(data%i == 0){
			return 0;
		}
	}
	return 1;
}

int main(void){
	int data,cnt=0,i;
	while(std::cin >> data){
		for(i=2;i<=data;i++){
			if(prime(i)){
				cnt++;
			}
		}
		std::cout << cnt << std::endl;
	}
}

C++: #include<iostream>
#include<vector>
#define MAX 1000000
using namespace std;
int main(){
    vector<int> v(MAX);
    for(int i = 0;i<MAX;i++)
      v[i]=true;

      v[0]=false;
      v[1]=false;
    for(int i = 2;i<MAX;i++){
      if(v[i]==true){
        for(long long int  = (long long int)i*i;j<MAX;j=j*j){
         v[j]=false;
       }
      }
    }
    for(int i = 2;i<MAX;i++)v[i]+=v[i-1];
    while(true){
      int a;
      cin >> a;
      if(cin.eof())return 0;
      cout << v[a]<<endl;
    }
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#define MAX 1000000
using namespace std;
int prime[1000009];
void sive()
{
    int i,j,k,c=0;
    prime[0]=1;
    prime[1]=1;
    for(i=2;i*i<=1000009;i++)
    {
        if(prime[i]==0)
        {
            for(j=i+i;j<1000009;j+=i)
            {
                prime[j]=1;
            }
        }
    }
}
int main()
{
    int st,en,i,c=0,co;
    int b[100];
    sive();
     //printf("1");

    while(scanf("%d",&en)==1)
    {
        co=0;
    for(i=2;i<=en;i++)
    {
        if(prime[i]==0)
        //printf("1");
        {
            co++;
        }
    }
            printf("%d\n",co);
    }

    return 0;
}

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

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

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <stdio.h>

#define MAX 1000000

using namespace std;

int main()
{
	char p[MAX]={1,1};
	int n,ans;

	for(int i=2;i*i<=MAX;i++){
		if(p[i]==0){
			for(int j=i*2;j<MAX;j+=i) p[j]=1;
		}
	}

	while(cin>>n){
		ans=0;
		for(int i=2;i<=n;i++){
			 if(p[i]==0) ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, int> ll_i;
struct edge { int u, v; ll w; };

void sieve(int n, bool a[]) {
	fill(a, a + n, true);
	a[0] = a[1] = false;
	for (int i = 2; i * i < n; i++)
		if (a[i])
			for (int j = i * 2; j < n; j += i)
				a[j] = false;
}

bool a[1000000];
int b[1000000];

int main() {
	sieve(1000000, a);
	for (int i = 1; i < 1000000; i++)
		b[i] = b[i - 1] + (a[i] ? 1 : 0);
	int n;
	while (cin >> n) cout << b[n] << endl;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n,a[9];
	a[0]=9592;
	a[1]=17984;
	a[2]=25997;
	a[3]=33860;
	a[4]=41538;
	a[5]=49098;
	a[6]=56543;
	a[7]=63951;
	a[8]=71274;
	while(cin>>n){
		int count=0;
		int i=0;
		while(true){
			if((i+1)*100000<=n)
				count=a[i];
			else
				break;
			i++;
		}
		if(n<100000){
			count=1;
			for(int j=3;j<=n;j++){
			bool t=false;
			for(int k=2;k<1+(double)sqrt((double)j);k++){
				if(j%k==0)
					t=true;
			}
			if(t==false)
				count++;
		    }
		}
		else{
		    for(int j=(i)*100000+1;j<=n;j++){
			    bool t=false;
			    for(int k=2;k<1+(double)sqrt((double)j);k++){
				    if(j%k==0)
				        t=true;
			    }
			    if(t==false)
				    count++;
		    }
		}
		cout<<count<<endl;
	}
	return 0;
}

C++: #include <stdio.h>
int main()
{
  int i,j,cou=0,n;
  while(scanf("%d",&n)!=EOF){
    cou=0;
    for(i=2;i<=n;i++){
      if(i==2){
	cou++;
	continue;
      }
      for(j=2;j<i;j++){
	if(i%j==0)break;
	if(j==i-1)cou++;
      }
    }
    printf("%d\n",cou);
  }
  return 0;
}