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 ham[1000001];
int m,n;

void solve(){
	ham[1] = true;
	for(int i=2; i<1000001; i++)
		ham[i] = false;
	for(int i=1; i<1000001; i++){
		if(ham[i]){
			for(int j=i*2; j<1000001; j*=2)
				ham[j] = true;
			for(int j=i*3; j<1000001; j*=3)
				ham[j] = true;
			for(int j=i*5; j<1000001; j*=5)
				ham[j] = true;
		}
	}
}

int main(){
	solve();
	while(true){
		cin >> m >> n;
		if(!m && !n)
			return 0;
		int ans = 0;
		for(int i=m; i<=n; i++)
			if(ham[i])
				ans++;
		cout << ans << endl;
	}
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(long i=0;i<(n);i++)
#define RREP(i,n) for(long i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    vector<long> two;
    vector<long> three;
    vector<long> five;
    vector<long> num;
    two.PB(1);
    three.PB(1);
    five.PB(1);
    for(long i=1;two.back()<1e6;i++){
	two.PB(two.back() * 2);
    }
    for(long i=1;three.back()<1e6;i++){
	three.PB(three.back() * 3);
    }
    for(long i=1;five.back()<1e6;i++){
	five.PB(five.back() * 5);
    }
    for(long i=0;i<two.size();i++){
	for(long j=0;j<three.size();j++){
	    for(long k=0;k<five.size();k++){
		if(two[i] * three[j] * five[k] <= 1e7)
		    num.PB(two[i] * three[j] * five[k]);
	    }
	}
    }
    sort(ALL(num));
    while(true){
	long n,m;
	cin >> m;
	if(m == 0) break;
	cin >> n;
	long ans  = upper_bound(ALL(num),n) -  lower_bound(ALL(num),m);
	cout << ans << endl;
    }
    return 0;
}

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

const int N = 1000000;
bool haming[N];

int main(){
    int m, n;
    fill(haming, haming + N, false);
    for(int i = 1;i < N;i <<= 1){
        for(int j = 1;i * j < N;j *= 3){
            for(int k = 1;i * j * k < N;k *= 5){
                haming[i * j * k] = true;
            }
        }
    }
    while(cin >> m, m){
        int c = 0;
        cin >> n;
        for(int i = m; i <= n;++i){
            if(haming[i]) ++c;
        }
        cout << c << endl;
    }
    return 0;
}

C++: #include "math.h"

#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
using namespace std;
typedef long long  ll;
/** Problem0162 : Hamming Numbers **/
int main()
{
	set<int> h;

	rep(i, 20) {
		rep(j, 20) {
			rep(k, 20) {
				h.insert(pow(2.0, i)*pow(3.0, j)*pow(5.0,k));
			}
		}
	}
	
	int m, n, ans;
	while (cin>>m>>n, m) {
		ans=0;
		set<int>::iterator it = h.begin();
		for (; it!=h.end(); it++) {
			if (m<=*it && *it<=n) {
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
int main() {
	int m,n,count=0,a;
	while(true){
		cin>>m;
		if(m==0){
			break;
		}
		else{
			cin>>n;
			for(int i=m;i<n+1;i++){
				a=i;
				while(true){
					if(a%2==0){
					a/=2;
					}
					if(a%3==0){
					a/=3;
					}
					if(a%5==0){
					a/=5;
					}
					if(a%2!=0&&a%3!=0&&a%5!=0){
					break;
					}
				}
					if(a==1){
					count++;
					}
			}
			cout<<count<<endl;
			count=0;
		}
	}
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

int main() {
  int N = 1000000;
  bool dp[N+1];
  dp[1] = true;
  for (int i=2; i<=N; ++i) {
    if (i%2==0&&dp[i/2] || i%3==0&&dp[i/3] || i%5==0&&dp[i/5]) {
      dp[i] = true;
    } else {
      dp[i] = false;
    }
  }
  int m,n;
  while(cin>>m,m) {
    cin >> n;
    cout << count(dp+m, dp+n+1, true) << endl;
  }
}

C++: #include<iostream>
using namespace std;
bool t[1000001];
int  u[1000001];
int N =1000000;
int n,m;
void make_table(){
  for(int i=0;i<=N;i++)t[i]=false,u[i]=0;
  t[1]=true;
  for(int i=1;i<=N/2;i++){
    u[i]=u[i-1];
    if(t[i]==false)continue;
    u[i]++;
    if(i*2<=N)t[i*2]=true;
    if(i*3<=N)t[i*3]=true;
    if(i*5<=N)t[i*5]=true;
  }
}



int main(){
  make_table();
  while(cin>>n>>m){
    cout<<u[m]-u[n]+t[n]<<endl;
  }
}

C++: #include <iostream>

using namespace std;

bool is_hamming(int n) {
    while (true) {
        if (n % 5 != 0) break;
        n /= 5;
    }
    while (true) {
        if (n % 3 != 0) break;
        n /= 3;
    }
    while (true) {
        if (n % 2 != 0) break;
        n /= 2;
    }
    if (n == 1) return true;
    else return false;
}

int main() {
    int a, b;
    while (cin >> a) {
        if (a == 0) break;
        cin >> b;
        int count = 0;
        for (int i = a; i <= b; i++) {
            if (is_hamming(i)) count++;
        }
        cout << count << endl;
    }
    return 0;
}

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

typedef vector<int> vi;

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

int const M=1000000+10;

vi init(){
    int n=1;
    vi hs;
    hs.reserve(2<<20);
    for(int x=1;x<M;x*=2){
        for(int y=1;x*y<M;y*=3){
            for(int z=1;x*y*z<M;z*=5){
                hs.emplace_back(x*y*z);
            }
        }
    }
    return hs;
}

int main(){
    int m,n;
    vi hs=init();
    sort(all(hs));
    while(cin>>m>>n && m){
        auto x=lower_bound(all(hs),m);
        auto y=upper_bound(all(hs),n);
        cout<<y-x<<endl;
    }
}

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

set<int> hamming;
void make_hamming() {
  for(int i=0; i<20; i++) 
    for(int j=0; j<20; j++)
      for(int k=0; k<20; k++)
	hamming.insert(pow(2.0, i)*pow(3.0, j)*pow(5.0, k));
}

int main() {
  make_hamming();
  int m, n;
  while(cin >> m >> n && m) {
    set<int>::iterator it = hamming.begin();
    int cnt = 0;
    for(it; it!=hamming.end(); it++) {
      if(m<=*it && *it <=n) cnt ++;
    }
    cout << cnt << endl;
  }
  return 0;
}

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

int main(){
int num;
int sum[N];
int n,m;

sum[0] = 0;
num = 0;
for(int i=0;i<N;i++){
int tmp = i;
while(!(tmp%2))tmp/=2;
while(!(tmp%3))tmp/=3;
while(!(tmp%5))tmp/=5;
if(tmp==1)num++;
sum[i] = num;
}
while(1){
cin >> m;
if(!m)break;
cin >> n;
cout << sum[n] - sum[m-1] << endl;
}
}