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<cstdio>
#include<cstring>
int main(){
 int n,cnt=0;
 scanf("%d",&n);
 int a[n+1];
 memset(a,-1,sizeof(int)*(n+1));
 for(int i=2;i<=n;i++){
 if(a[i]==-1){ con++;
 for(int j=i;j<=n;j=j+i) a[j]=0;}
}
return 0;
}

C++: #include <bits/stdc++.h>
#define ll long long
#define un unsigned
#define de double
#define pi acos(-1.0)
#define FF first
#define SS second
#define pb push_back
#define mp make_pair
#define mem(ae, value) memset(ae, value, sizeof(ae))
#define all(x) x.begin( ), x.end( )
#define UNIQUE(x) x.resize(unique(all(x)) - x.begin())
#define FASTER ios_base::sync_with_stdio(0)
#define loop(begin, end) for(u int i=begin; i<=end; i++)
#define Read freopen("in.txt", "r", stdin)
#define Write freopen("out.txt", "w", stdout)
#define nl '\n'

using namespace std;

template<class T> inline T sq(T x) { return x*x; }
template <class T> inline T gcd(T a, T b) { if(b == 0) return a; return GCD(b, a%b); }
template <class T> inline T lcm(T a, T b) { return ( a/GCD(a, b) ) * b; }
template <class T> inline T power(T b, T p)
{
    if(p == 0) return 1;
    if(p == 1) return b;
    if(p&1) return b*power(b, p-1);
    else return sq(power(b, p>>1));
}

bool P[500000+10];

void sieve(int n)
{
    for(int i=3; i*i<=n; i+=2)
    {
        if( (P[i/2-1]) == 0 )
        {
            for(int j=i*i; j<=n; j+=2*i)
            {
                P[j/2-1] = 1;
            }
        }
    }
}

void display()
{
    for(int i=0; i<60; i++)
    {
        cout << i << " = " << (i*2+3) << " --- " << P[i] << nl;
    }
}


int main( )
{
    sieve(500000);
    int n;
    while(cin >> n)
    {
        int C=0;
        if( (n==1) or (n==2))
        {
            if(n==1) C=0;
            else
            {
                if(n==2) C=1;
            }
        }
        else
        {
            int upto;
            if((n&1))
            {
                upto = n/2 - 1;
            }
            else
            {
                upto = n/2 - 2;
            }
            int i=0;
            while(i<=upto)
            {
                if(P[i]==0) C ++;
                i ++;
            }
            C ++;
        }
        cout << C << nl;
    }
    //display( );

    return 0;
}

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

int main()
{
	int n=0;
	int a[40]={0};
	while(cin>>a[n++]);n--;
	
	int maxn=1000000;
	bool p[maxn];
	for(int i=0;i<maxn;i++)
	{
		p[i]=1;
	}
	for(int i=2;i<maxn;i++)
	{
		for(int j=i+i;j<maxn;j+=i)
		{
			p[j]=0;
		}
	}
	
	for(int i=0,cnt=0;i<n;i++)
	{
		for(int j=2;j<=a[i];j++)
		{
			cnt+=p[j];
		}
		cout<<cnt<<endl;cnt=0;
	}
	return 0;
}

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


int main() {

//変数の宣言

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

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,count,sc;
  while(cin>>n){
    count = 0;
    for(int i=2;i<=n;i++){
      sc = 0;
      for(int j=2;j<=i;j++) if(i%j==0) sc++;
      if(sc==1) count++;
    }
    cout << count << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
using namespace std;

int main(){
  int n;
  while(cin >> n){
    int ans=0;
    vector<int> vec;
    vec.push_back(2);
    for(int i = 3; i<=n; i+=2){
      bool isPrimeN = true;
      for(auto&& num : vec){
        if(i%num==0){
           false;
        }
      }
      for(int j=3; j<=floor(sqrt(i)); j++){
        if(i%j==0){
          isPrimeN = false;
          break;
        }
      }
      if(isPrimeN){
        vec.push_back(i);
      }
    }
    cout << vec.size() << endl;;
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); ++i)

bool isPrime[999999];

int main(void){
    int n;
    while(cin >> n) {
        rep(i, n+1) isPrime[i] = true;
        for(int i=2; i*i <= n; ++i) {
            if(isPrime[i]) {
                for(int j=2; i*j <= n; ++j) {
                    isPrime[i*j] = false;
                }
            }
        }
        int ans = 0;
        for(int i=2; i<=n; ++i) {
            if(isPrime[i]) ans++;
        }
        cout << ans << endl;
    }
}

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

int main(){
int unti[100001] = {0};
fill(unti,unti + 100001,0);
for(int n = 2;n < 100001;n++)
{
if(unti[n] == 0)
{
for(int a = 2;(a * n) < 100001;a++)
{
	if((a * n  ) < 100001 ) unti[a * n]++;
}
}
}
int b;
while(cin >> b )
{
int cnt = (count(unti,unti+b+1,0) - 2);
cout << cnt ;
	}


}

C++: #include<iostream>
using namespace std;
int main()
{
	int n,S;
while(cin>>n)
{
	S=0;
	if(n==1)
	{
		cout<<0<<endl;
	}
	for(int i=2;i<=n;i++)
	{
		for(int j=i-1;j>1;j--)
		{
			if(i%j==0)
			{
				break;
			}
			if(j==2)
		{
			S++;
		}
		}	
			
	}
	cout<<S<<endl;
}
return 0;
}

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

int p[1000010];

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

C++: #include<iostream>

#define bound 1000000

int main()
{
  bool is_prime[bound] = {};
  for (int i = 2; i < bound; i++)
    is_prime[i] = true;
  for (int prime = 2; prime < bound; ++prime)
    {
      if (!is_prime[prime]) continue;
      for (int i = prime * 2; i < bound; i += prime)
	is_prime[i] = false;
    }

  int table[bound] = {};
  for (int i = 0; i < bound; ++i)
      table[i] = table[i - 1] + is_prime[i];

  int n;
  while(std::cin >> n)
      std::cout << table[n] << std::endl;

  return 0;
}

C++: #include<iostream>
#include<math.h>
using namespace std;
int main(){
	int i,j,number,count=0,hantei=0;
	while(cin>>number){
		count=0;
		for(i=2;i<number;i++){
			hantei=0;
			for(j=0;j<sqrt(i);j++){
				if(i%j==0){
					hantei++;
				}
			}
			if(hantei==0){
				count++;
			}
		}
		cout<<count<<endl;
	}
	return 0;
}

C++: #include <iostream>

bool prime(int n);

int main(void) {
	using namespace std;
	int x;
	int count;
	while (cin >> x) {
		count = 0;
		for (int i = 2; i <= x; i++) {
			if (prime(i))count++;
		}
		cout << count << endl;
	}
	return 0;
}

bool prime(int n) {
	static int flag = 0; 
	static int count = 0;
	static int list[78498];

	if (flag == 1) {
		for (int j = 0; j < count; j++) {
			if (n % list[j] == 0 ) {
				if (n == list[j]) {
					return true;
				}
				
				return false;
				
				
			}
		}
	}

	
	flag = 1;
	list[count] = n;
	count++;
	return true;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main(){
	int i, j, n, *prime;
	while(cin >> n){
		int ans = 0;
		prime = new int[n];
		for(i = 0; i < n; ++i) prime[i] = 1;
		prime[0] = 0;
		for(i = 1; i < sqrt(n); ++i){
			if(prime[i] == 1){
				for(j = (i + 1); (i + 1) * j <= n; ++j){
					prime[(i + 1) * j - 1] = 0;
				}
			}
		}
		for(i = 0; i < n; ++i){
			if(prime[i] == 1) ++ans;
		}
		cout << ans << endl;
	}
	return 0;
}