Go: package main

import (
	"bufio"
	"os"
		"strings"
	"strconv"
			"fmt"
	)

var scanner = bufio.NewScanner(os.Stdin)
const (
	MAX = 1000000
)
func main() {
	a := make([]int, MAX+1)
	a[1] = 1
	for i := 2; i <= MAX; i *= 2 {
		a[i]++
	}
	for i := 1; i <= MAX; i++ {
		if a[i] != 0 {
			for j := i*3; j <= MAX; j *= 3 {
				if a[j] == 0 {
					a[j]++
				}
			}
		}
	}
	for i := 1; i <= MAX; i++ {
		if a[i] != 0 {
			for j := i*5; j <= MAX; j *= 3 {
				if a[j] == 0 {
					a[j]++
				}
			}
		}
	}
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		m, _ := strconv.Atoi(buf[0])
		if m == 0 {
			break
		}
		n, _ := strconv.Atoi(buf[1])
		cnt := 0
		for i := m; i <= n; i++ {
			if a[i] != 0 {
				cnt++
			}
		}
		fmt.Println(cnt)
	}
}

C++: #include <iostream>

using namespace std;

bool P[1000001];
int a[3] = {2,3,5};

void init()
{
	for( int i = 0;i < 1000001;i++ ) P[i] = false;
	P[1] = true;
	for( int i = 1;i < 1000001;i++ ){
		if( P[i] ){
			for( int j = 0;j < 3;j++ ) if( i * a[j] < 1000001 ) P[i * a[j]] = true;
		}
	}
}

int main(int argc, char const* argv[])
{
	init();
	int m,n;

	while( cin >> m >> n && m != 0 ){
		int count = 0;
		for( int i = m;i <= n;i++ ) if( P[i] ) count++;
		cout << count << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

bool is_hamming[1000010];

void hamming(int n){
	memset(is_hamming,false,sizeof(is_hamming));
	queue<int> q;
	q.push(1);
	while(q.size()){
		int t=q.front(); q.pop();
		is_hamming[t]=true;
		if(2*t<=n) q.push(2*t);
		if(3*t<=n) q.push(3*t);
		if(5*t<=n) q.push(5*t);
	}
	return;
}

int sum[1000010];

signed main(){
	hamming(1000000);
	rep(i,1,1000001){
		sum[i]=sum[i-1];
		if(is_hamming[i]) sum[i]++;
	}
	int n,m;
	while(1){
		cin>>n;
		if(n==0) break;
		cin>>m;
		o(sum[m]-sum[n-1]);
	}
}

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

int humming[1000001];
void hum(void)
{
  int i;
  int f, c;
  for (i = 1; i <= 1000000; i++){
    c = i;
    while (1){
      f = 0;
      if (c % 2 == 0){
        c /= 2;
        f++;
      }
      if (c % 3 == 0){
        c /= 3;
        f++;
      }
      if (c % 5 == 0){
        c /= 5;
        f++;
      }
      if (f == 0){
        break;
      }
    }
    if (c == 1){
      humming[i] = 1;
    } else {
      humming[i] = 0;
    }
  }
}

int main(void)
{
  hum();
  int m, n;
  int cut;
  int i;

  while (1){
    cin >> m;
    if (m == 0){
      break;
    }
    cin >> n;
    cut = 0;
    for (i = m; i <= n; i++){
      cut += humming[i];
    }
    cout << cut << endl;
  }

  return (0);
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll; 
typedef pair<ll, ll> PL;

ll n, m;

int main(){
	while (cin >> m){
		if (m == 0)break;
		cin >> n;
		ll c = 0;
		FOR(i, m, n + 1){
			FOR(j, 1, 11){
				ll x = pow(60.0, (double)j);
				if (x % i == 0){
					c++;
					break;
				}
			}
		}
		cout << c << endl;
	}
}

C++: #include<stdio.h>

int main(){
int x,y;
int N=1000000;
bool f[1000001];
for(int i=0;i<N;i++)
f[i]=false;
int c=0;

for(int i=0;i<N;i++)
{if(i%2==0||i%3==0||i%5==0)
f[i]=true;
}

for(int i=0;i<N;i++)
{if(i%7==0)
f[i]=false;
}

while(1){

scanf("%d",&x);if(x==0)break;

scanf("%d",&y);

for(int i=x;i<=y;i++)
if(f[i]==true)c++;

printf("%d\n",c);

}

return 0;
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<double,double> P;
typedef complex<double> CP;
typedef long long ll;

bool a[1000010];
int b[1000010]={0};

int main(){
	rep(i,1000010){
		a[i]=false;
	}
	a[1]=true;
	for(int i=1;i<1000010;i++){
		if(a[i]){
			if(2*i<1000010) a[2*i]=true;
			if(3*i<1000010) a[3*i]=true;
			if(5*i<1000010) a[5*i]=true;
		}
	}
	/*
	rep(i,100){
		if(a[i]){
			cout<<i<<" ";
		}
	}
	cout<<endl;
	*/
	rep(i,1000010){
		if(i==0) continue;
		b[i]=b[i-1];
		if(a[i]) b[i]++;
	}
	int m,n;
	while(cin>>m,m){
		cin>>n;
		cout<<b[n]-b[m]+1<<endl;
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0;i < n;i++)

const int N = 1000000;
int hamming[N];

int main() {
    rep(i, N) hamming[i] = true;

    hamming[0] = false;
    rep(i, N) {
        if(!hamming[i]) continue;
        if(i == 1 || i % 2 == 0 || i % 3 == 0 || i % 5 == 0) continue;

        for(int j = i * 1; j < N;j += i) {
            hamming[j] = false;
        }
    }

    while(1) {
        int m, n;
        cin >> m;
        if(!m) break;
        cin >> n;

        int ans = 0;
        for(int i = m;i <= n;i++) {
            if(hamming[i]) ans++;
        }
        cout << ans << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    bool s[1000005] = {0}, f;
    s[1] = true;
    s[0] = false;
    int i = 1;
    rep(i, 1000005){
        if(s[i] == true){
            if(i * 2 < 1000005){
                s[i * 2] = true;
            }
            if(i * 3 < 1000005){
                s[i * 3] = true;
            }
            if(i * 5 < 1000005){
                s[i * 5] = true;
            }
        }
    }
    int m,n;
    while(cin >> m, m){
        cin >> n;
        int ans = 0;
        range(j, m, n + 1){
            if(s[j] == true)
                ans++;
        }
        cout << ans << endl;
    }
}

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

bool ishamming[1000001];
bool isHamming(int i) {
  int x = i;
  if(x % 5 == 0) x /= 5;
  if(x % 3 == 0) x /= 3;
  if(x % 2 == 0) x /= 2;
  if(ishamming[x]) {
    ishamming[i] = true;
    return true;
  } else {
    ishamming[i] = false;
    return false;
  }
}

main() {
  int hammingNum[1000001];
  hammingNum[1] = 1;
  ishamming[1] = true;
  for(int i = 2; i <= 1000000; i++) {
    hammingNum[i] = hammingNum[i-1];
    if(isHamming(i)) hammingNum[i]++;
    if(i <= 20) {
    }
  }
  while(1) {
    int m, n;
    cin >> m;
    if(m == 0) break;
    cin >> n;
    cout << hammingNum[n] - hammingNum[m-1] << endl;
  }
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

bool hamming[1000000];
int main()
{
  const int c = 12960000;
  int m, n;

  REP(i, 1000000){
    if (c % (i + 1) == 0) hamming[i]++;
  }

  while (cin >> m, m){
  	cin >> n;
    int cnt = 0;
    FOR(i, m - 1, n){
      if (hamming[i]) cnt++;
    }
    cout << cnt << endl;
  }
}