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 := 2; i <= num; i++ { //1を除く入力値以下の数字
			for j := i - 1; j >= 1; j-- {
				if i%j == 0 && j != 1 {
					flag = true
					break
				}
			}
			if !flag {
				count++
			} else {
				flag = false
			}
		}
		fmt.Println(count)
	}
}

C++: #include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <set>
#include <vector>

std::vector<std::size_t> prime_table = {2};

void make_prime_table()
{
    std::set<std::size_t> undefined_table;
    for(std::size_t i = 3; i <= 999999; i += 2)
    {
        undefined_table.insert(i);
    }

    const std::size_t sn = 1000;
    for(std::size_t p = 0; !undefined_table.empty() && p < prime_table.size(); ++p)
    {
        for(auto u = undefined_table.begin(); u != undefined_table.end();)
        {
            if(0 == *u % prime_table[p])
            {
                u = undefined_table.erase(u);
            }
            else
            {
                ++u;
            }
        }

        if(!undefined_table.empty())
        {            
            prime_table.push_back(*undefined_table.begin());
            undefined_table.erase(undefined_table.begin());
            if(sn <= prime_table.back())
            {
                break;
            }
        }
    }
    prime_table.insert(prime_table.end(), undefined_table.begin(), undefined_table.end());
}

std::array<std::size_t, 1000000> prime_acc = {{0, 0}};

void make_prime_acc()
{
    std::size_t acc_found = 1;
    for(auto p = prime_table.begin(); p != prime_table.end(); ++p)
    {
        std::fill_n(prime_acc.begin() + acc_found + 1, *p - acc_found - 1, prime_acc[acc_found]);
        acc_found = *p;
        prime_acc[acc_found] = prime_acc[acc_found - 1] + 1;
    }
    std::fill(prime_acc.begin() + acc_found + 1, prime_acc.end(), prime_acc[acc_found]);
}

int main()
{
    make_prime_table();
    make_prime_acc();

    std::size_t n;

    while(std::cin >> n, !std::cin.eof())
    {
        std::cout << prime_acc[n] << std::endl;
    }
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int main(){
	int n,k,kk;
	while(cin>>n){
		kk=0;
		for(int j=3;j<=n;j+=2){
			k=0;
			for(int i=3;i<=sqrt(j);i+=2){
				if(j%i==0)k++;
		        }
		     if(k==1)kk++;
		   }
		if(n==1)cout<<"0"<<endl;
		else if(n==2)cout<<"1"<<endl;
		else cout<<kk+1<<endl;
	   }
	return 0;
	}

C++: #include<iostream>
using namespace std;
int prime[1200000];
int main(){
	for(int i=2;i<1200000;i++)prime[i]=1;
	for(int i=2;i*i<1200000;i++){
		for(int j=i*i;j<1200000;j+=i){
			prime[j]=0;
		}
	}
	for(int i=2;i<1200000;i++)prime[i]+=prime[i-1];
	int n;
	while(cin>>n){
		cout<<prime[n]<<endl;
	}
}

C++: #include <iostream>

using namespace std;

bool isPrime(int n){
	
	if (n == 1)
		return false;
	if (n == 2)
		return true;

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

int main(){
	int n;

	while (cin >> n){
		int c = 0;
		for (int i = 1; i <= n;++i){
			if (isPrime(i))
				++c;
		}
		cout << c << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
  int i, j, n, isFound;
  vector<int> prime;

  while(cin >> n){
    for(i=2; i<=n; ++i){
      isFound = 1;
      for(j=0; j < prime.size(); ++j){
	if(i % prime[j] == 0){
	  isFound = 0;
	  break;
	}
      }
      if(isFound == 1)
	prime.push_back(i);
    }
    cout << prime.size() << endl;
    prime.clear();
  }

  return 0;
}

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

int num(int n)
{
    int a[1000000] = {1, 1};
    for (int i = 2; i <= n; ++i)
        for (int j = 2; i * j <= n; ++j)
            a[i * j] = 1;
    int cnt = 0;
    for (int i = 0; i <= n; ++i)
        if (a[i] == 0)
            ++cnt;
    return cnt;
}

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

C++: #include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
bool primenum(int a)
{
    int i;
    int s;
    s=(int)sqrt(a)+1;
    if(a==2) return true;
    for(i=2;i<=s;i++)
    {
        if(a%i==0)
        {
            break;
        }
    }
    if(i==s+1)
    {
        return true;
    }
    else
        return false;
}
int main()  
{  
    int n;
    while(cin>>n)
    {

    
        int counter=0;
        for(int j=2;j<=n;j++)
        {
            if(primenum(j))
            {
                counter++;
            }
            
        }
        cout<<counter<<endl;
    }
    //system("pause");
    return 0;
}

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

int main(void) {
    int n;
    while(cin >> n) {
        int a[n];
        for(int i = 0; i <= n; i++) {
            a[i] = 1;
        }
        for(int i = 2; i < sqrt(n); i++) {
            if(a[i]) {
                for(int j = 0; i * (j + 2) <= n; j++) {
                    a[i * (j + 2)] = 0;
                }
            }
        }
        int cnt = 0;
        for(int i = 2; i <= n; i++)
            if (a[i]) cnt++;
        cout << cnt << endl;
    }
}

C++: #include <stdio.h>

int main(void) {

  int n;
  int num;
  int i,p,k,count;
  int flag[1000000];

  while(scanf("%d",&n)!=EOF) {

    num=(n-3)/2;

    for(i=0;i<=num;i++) {
      flag[i]=1;
    }

    for(i=0;i<=num;i++) {
      if(flag[i]==1) {
	p=i+i+3;
	printf("%d\n",p);

	for(k=i+p;k<=num;k+=p) {
	  flag[k]=0;
	}
      }
    }
  }

  return 0;
}

C++: #include <iostream>
//#include <stdio.h>
using namespace std;
int main() {
  
  //char str[10];
  long n,i=1,count=0;
  //long exp=1,result[10]={0,0,0,0,0,0,0,0,0,0};

  cin >> n;

  while(i<=n) {
    if(n%i==0) count++;
    i++;
  }

  printf("%ld",count);
  return 0;
}

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

int prime(int x) {
	for (int i = 2; i < sqrt(x) + 1; i++) {
		if (x%i == 0) return 0;
	}
	return 1;
}
int main(){
	int n;
	while (scanf("%d", &n) != EOF){
		int count = 0;
		for (int i = 2; i <= n; i++) {
			if (prime(i))count++;
		}
		count++;
		if (n == 0)count = 0;
		if (n == 1)count = 0;
		if (n == 2)count = 1;
		printf("%d\n", count);
	}
	return 0;
}

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

bool check(int in){
	for (int i = 3; i<=sqrt(in); i+=2){
		if (i != 5 && i % 5 == 0)	continue;
		if (in % i == 0)
			return false;
	}
	return true;
}

int PrimeNumber(int in, int start){
	int count = 0;
	if (in >= 2 && start==3)	count++;
	for (int i = start; i <=in; i+=2){
		if (check(i))	count++;
	}

	return count;
}

int main(){
	int in;
	int count250000 = PrimeNumber(250000, 3);
	int count500000 = count250000 + PrimeNumber(500000, 250001);
	int count750000 = count500000 + PrimeNumber(750000, 500001);

	while (cin >> in, !cin.eof()){
		if (in <= 250000)
			cout << PrimeNumber(in, 3) << endl;
		else if (in <= 500000)
			cout << count250000 + PrimeNumber(in, 250001) << endl;
		else if (in <= 750000)
			cout << count500000 + PrimeNumber(in, 500001) << endl;
		else
			cout << count750000 + PrimeNumber(in, 750001) << endl;
	}
}

C++: #include <iostream>
using namespace std;
typedef long long int LL;
#define MOD 1000000007

LL pow(LL m, LL n)
{
	LL res = 1,x = 1,a = m;
	while (x <= n) {
		if ((x & n) > 0) {
			res *= a;
			res %= MOD;
		}
		a *= a;
		a %= MOD;
		x <<= 1;
	}
	res %= MOD;
	return res;
}

int main()
{
	LL m, n;
	cin >> m >> n;
	cout << pow(m,n) << endl;
	return 0;
}