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 <iostream>
#include <vector>
using namespace std;
int main(){
int n;
cin >> n;
vector<int> prime;
prime.push_back(2);//ôðÈ­½ß2ÍÅÉüêÄ¨­
bool flag;
for(int x=3;x<=n;x+=2){
flag=true;
for(int y=0;prime[y]*prime[y]<=x;y++){
if(!(x%prime[y])){
flag=!flag;
break;
}
}
if(flag)prime.push_back(x);
}
cout << prime.size() << endl;
return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int prime(int);
int main(){
    int a,sum;
    int b[999999];
    b[0]=0;
    for(int i=1;i<999999;i++){
        b[i]=prime(i);
    }
    while ( cin >> a){
        sum =0;
        for (int i=1;i<a;i++){
            sum +=b[i+1];
        }
        cout << sum << endl;
    }
}
int prime(int x){
    if(x==1)
        return 0;
    if(x==2)
        return 1;
    for (int i=2;i<=sqrt(x)+1;i++){
        if(x%i==0)
            return 0;
    }
    return 1;
}

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

int setPrimeNumberCount(int n) {
    int count = 0;
    bool primeFlag = true;
    
    if(n >= 2) {
        count++;
    }
    
    for(int i = 3; i <= n; i+=2) {
        for(int j = 3; j < i; j+=2) {
            if(i % j == 0) {
                primeFlag = false;
                break;
            }
        }
        if(primeFlag) {
            count++;
        }
        primeFlag = true;
    }
    return count;
}

int main(void) {
    int n;
    int count = 0;
    
    while(cin >> n) {
        count = setPrimeNumberCount(n);
        cout << count << endl;
        count = 0;
    }
    return 0;
}

C++: #include <stdio.h>
#include <math.h>
int sosuu(int x){
    int n,m,sosuu;
    sosuu=x-2;
    for(n=2;n<x;n++){//nは素数を調べる。入力された数字まで１からスライドしていく。
        for(m=2;m<n;m++){//mはnが素数かどうか調べる。素数かどうかをnより小さい数字で数えていく。2からなのは2から素数だから。1はふくめない。
            if(n%m==0){//素数じゃなかったら、つまり割り切れてしまったら。
                sosuu--;
            }
           
            if(n%m==0) break;
        }
    }
    if(x==1||x==0) sosuu=0;
    return sosuu;
}

int main ( void ) {
    int s,result;
    scanf("%d",&s);
        result = sosuu(s);
        printf("%d\n",result);
    
    return 0;
}

C++: #include"iostream"
#include"math.h"
#define ll long long 
using namespace std;
int snt(ll n)
{
 ll i;
 ll m;
 if(n == 2 || n == 3)
  return 1;
 if (n == 1||n % 2 == 0||n % 3 == 0)
  return 0;
 m = (int)sqrt(n);
 for(i=5;i<=m;i=i+6)
  if(n % i == 0 || n % (i+2) == 0) return 0;
 return 1;
}
ll lam(ll n)
{
	ll d=0;
	for(ll i=2;i<=n;i++)
	{
		if(snt(i))
		d++;
	}
	return d;
}
int main()
{
	ll n;
	do
	{
		cin>>n;
		cout<<lam(n);
		cout<<endl;
	}while(1);
}

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

using namespace std;

int main()
{
    int n, flag, c = 1;
    long long a[99999];
    for(int i=2; i<=99999; i++)
    {
        flag = 0;
        for(int j=2; j<=sqrt(i); j++)
        {
            if(i % j == 0)
            {
                flag = 1;
            }
        }
        if(flag == 0)
        {
            a[i] = 1;
        }
        else
        {
            a[i] = -1;
        }
    }

    while(scanf("%d",&n) != EOF)
    {
        int m = 0;
        for(int i=2; i<=n; i++)
        {
            if(a[i] == 1)
            m++;
        }

        cout<<m<<endl;
    }
}

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

bool prime(int m){
	if(m < 2)return false;
	if(m == 2)return true;
	if(m%2 == 0)return false;
	for(int i = 3; i*i <= m; i += 2){
		if(m%i == 0)return false;
	}
		return true;
}

int main(){
	int n;
	
	while(cin >> n){
		int a=0;
		for(int i = 1; i <= n; ++i){
			if(prime(i))++a;
	}
		cout << a << '\n';
	}
}

C++: #include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>


/*
	HOME-  Volume0-0009
	Submit Statistics
	 
	PCK 2003
	Prime Number
	Time Limit : 1 sec, Memory Limit : 32768 KB
	English version is here
	Prime Number

	6 ÈºÌ³Ì® n ðüÍµAn ÈºÌfª¢­Â é©ðoÍ·évOðì¬µÄº³¢B½¾µAfÆÍ 1 Æ©ª©gÅµ©èØêÈ¢³Ì®Ì¤¿ 1 ðÌ¼¢½àÌð¢¢Ü·Bá¦Î 10 ÈºÌfÍA2, 3, 5, 7 Å·B
	Input

	¡Ìf[^Zbgª^¦çêÜ·Bef[^ZbgÉ n ªPsÉ^¦çêÜ·BüÍÌÅãÜÅµÄº³¢B
	Output

	ef[^Zbg²ÆÉAn ÈºÌfÌÂðPsÉoÍµÄº³¢B
	Sample Input

	10

	Output for the Sample Input

	4

*/

using namespace std;


int main()
{
	string s;
	
	while (getline(cin, s))
	{
		int n;
		sscanf(s.c_str(), "%ld", &n);
		
		vector<int> v;
		v.reserve(n);
		
		for (int i = 0; i <= n; i++)
		{
			v.push_back(1);
		}
		v[0] = 0;
		v[1] = 0;
		
		for (int i = 2; i <= n; i++)
		{
			for (int k = i + 1; k <= n; k++)
			{
				if (0 == (k % i))
				{
					v[k] = 0;
				}
			}
		}
		
		int x = 0;
		for (vector<int>::iterator it = v.begin(); it != v.end(); it++)
		{
			if (*it)
			{
				x++;
			}
		}
		
		printf("%d\n", x);
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
const int len = 20;

int main()
{
    int arr[30] = {0},n,count=0;
     cin>>n;
    for (int i = 2; i < n; i++)
    {
        for (int j = i * i; j < n; j+=i)
        {
            arr[j - 1] = 1;
        }
    }
    for (int i = 1; i <n; i++)
    {
        if ((arr[i - 1] == 0)&&(i>1))
            count++;
    }
    std::cout <<count<<endl;
}

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

typedef unsigned int Int;

Int sqrt_prm(const Int& target, Int x = 0) {
	while (x*x < target) {
		x++;
	}
	return x;
}

int main() {
	while (not std::cin.eof()) {
		Int target;
		std::cin >> target;

		std::vector<Int> primes = {};
		Int sqrt = 1;
		for (Int n = 3; n <= target; n+=2) {
			bool flag = true;

			sqrt = sqrt_prm(n, sqrt);
			for (auto&& p = primes.begin(); not(*p > sqrt or p == primes.end()); p++) {
				if (n % *p == 0) {
					flag = false;
					break;
				}
			}

			if (flag) {
				primes.push_back(n);
			}
		}

		std::cout << primes.size() + (target >= 2 ? 1 : 0) << std::endl;
	}
}

C++: 
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()

int main(void){
  static bool cmp[10000000] = {true};
  static int npr[10000000];
  loop(i,2,10000000){
    if(!cmp[i]){
      for(int j = 2 ; j * i < 10000000 ; j ++){
	cmp[i*j]=true;
      }
    }
    npr[i]=npr[i-1] + !cmp[i];
  }
  int n ;
  while(cin>>n){
    cout<<npr[n]<<endl;
  }
}