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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
static const int MAX=1000000;
bool judge(int n){
  while(n%2==0) n/=2;
  if(n==1) return true;
  while(n%3==0) n/=3;
  if(n==1) return true;
  while(n%5==0) n/=5;
  if(n==1) return true;
  return false;
}
int main(void){
  bool isHamming[MAX];
  for(int i=1; i<=MAX; i++){
    isHamming[i] = judge(i);
  }
  int m,n;
  while(cin>>m){
    if(m==0) break;
    cin>>n;
    int count=0;
    for(int i=m; i<=n; i++){
      if(isHamming[i]){
        count++;
      }
    }
    cout<<count<<endl;
  }
  return 0;
}

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

const long N=1000000;

int main(){
	long ham[550];
	long now=0;
	
	for(int i=0; i<20; ++i){
		for(int j=0; j<13; ++j){
			for(int k=0; k<9; ++k){
				long t=pow(2,i)*pow(3,j)*pow(5,k);
				if(t>N) break;
				ham[now++]=t;			
			}
		}
	}
	
	sort(ham, ham+now);
		
	while(1){
		long a, b, ans=0;
		scanf(" %ld", &a);
		if(a==0) break;
		scanf(" %ld", &b);
		
		for(long i=0; i<N; ++i){
			if(ham[i]>=a){
				now=i;
				break;
			}
		}
		
		for(long i=a; i<=b; ++i){
			if(ham[now]==i){
				++ans;
				++now;
			}
		}
	
		printf("%ld\n", ans);
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
bool flag[1000001];
int main() {
	long m,n; flag[1]=true;
	vector<long> v2,v3,v5;
	long tmp=2;
	while(tmp<=1e6) {v2.push_back(tmp); flag[tmp]=true; tmp*=2;}
	tmp=3;
	while(tmp<=1e6) {v3.push_back(tmp); flag[tmp]=true; tmp*=3;}
	tmp=5;
	while(tmp<=1e6) {v5.push_back(tmp); flag[tmp]=true; tmp*=5;}
	for(long i=0;i<v2.size();i++) {
		for(long j=0;j<v3.size();j++) {
			if(v2[i]*v3[j]>1e6) break;
			flag[v2[i]*v3[j]]=true;
		}
		for(long j=0;j<v5.size();j++){
			if(v2[i]*v5[j]>1e6) break;
			flag[v2[i]*v5[j]]=true;
		}
	}
	for(long i=0;i<v3.size();i++) {
		for(long j=0;j<v5.size();j++) {
			if(v3[i]*v5[j]>1e6) break;
			flag[v3[i]*v5[j]]=true;
		}
	}
	for(long i=0;i<v2.size();i++) {
		for(long j=0;j<v3.size();j++) {
			for(long k=0;k<v5.size();k++) {
				long long tmp=(long long)v2[i]*v3[j]*v5[k];
				if(tmp>1e6) break;
				flag[tmp]=true;
			}
		}
	}
	while(cin>>m>>n) {
		if(!m) break;
		long cnt=0;
		for(long i=m;i<=n;i++) if(flag[i]) cnt++;
		cout << cnt << '\n' ;
	}
}

C++: #include<iostream>
#include<algorithm>
#define MAXNUM 1e+6;

using namespace std;

int ham[4]={1,2,3,5};
bool memo[MAXNUM+1]={false};

void func(int n){
	if(n>MAXNUM || memo[n]==true){
		return ;
	}
	func(n*2);
	func(n*3);
	func(n*5);
}

int main(){
	int m,n,ans;
	func(1);
	
	while(cin>>m>>n,m){
		ans=0;
		for(int i=m;i<=n;i++){
			if(p[i]){
				ans++;
			}
		}
		cout<<ans<<endl;
	}
}

C++: #include<iostream>
using namespace std;
/*
bool sw[1000001];
int i;
 
void sws(int k){
        if(k==1){
                sw[i]=true;
                return;
        }
        if(k%2==0) sws(k/2);
        else if(k%3==0) sws(k/3);
        else if(k%5==0) sws(k/5);
        return;
}
*/
// korenisuru
int dp[1000001];
int f(int n){
        if(~dp[n]) return dp[n];
        int ans = 0;
        if(n%2==0) ans |= f(n/2);
        else if(n%3==0) ans |= f(n/3);
        else if(n%5==0) ans |= f(n/5);
        return dp[n] = ans;
}
 
int main() {
        int m,n;
        for(int i = 0 ; i <= 1000000 ; i++) dp[i] = -1;
        dp[1] = 1;
        for(int i = 1000000 ; i >= 1 ; i++) f(i);
        while(cin >> m && m){
                cin >> n;
                int ans = 0;
                for(int i = m ; i <= n ; i++) ans += dp[i];
                cout << ans << endl;
        }
        return 0;
}

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

using namespace std;

bool prime[10000];
int ans[1000001];

void erat()
{

    for (int i = 2; i < 10000; i++) {
        prime[i] = true;
    }

    for (int i = 2; i < 5000; i++) {
        if (prime[i]) {
            for (int j = 2; j*i < 10000; j++) {
                prime[i*j] = false;
            }
        }
    }
}

void solve()
{
    ans[0] = 0;
    for (int i = 1; i < 1000001; i++) {
        ans[i] = 1;
    }
    for (int i = 7; i < 1000001; i++) {
        if (prime[i]) {
            for (int j = 2; i*j < 1000001; j++) {
                ans[i*j] = 0;
            }
            ans[i] = 0;
        }
    }
    for (int i = 1; i < 1000001; i++) {
        ans[i] += ans[i-1];
    }
}




int main() 
{
    int m, n;
    cin >> m;

    erat();
    solve();

    while (m) {
        cin >> n;
        cout << ans[n] - ans[m-1] << endl;
        cin >> m;
    }
    return 0;
}

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#include<complex>
#define EPS 1e-10
using namespace std;
typedef long long llong;
static const int lim = 1000001;
vector<int> dp(lim,0);
int main() {

	for (int s = 1; s < lim; s *= 2) {
		for (int t = s; t < lim; t *= 3) {
			for (int u = t; u < lim; u *= 5) {
				dp[u] = 1;
			}
		}
	}
	for (int i = 1; i < lim; i++)dp[i] += dp[i - 1];


	int m, n;
	while (cin >> m >> n, m) {
		cout << dp[n] - dp[m - 1] << endl;
	}


	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;

vector<int> hamming_numbers;
int m, n;

void print_vi(vector<int> vi)
{
	rep(i, vi.size())
	{
		printf("%d ", vi[i]);
	}
}

signed main()
{
	rep(i,21) rep(j,13) rep(k,9)
	{
		int num = pow(2, i) * pow(3, j) * pow(5, k);
		if (num <= 1000000)
		{
			hamming_numbers.push_back(num);
		}
	}

	sort(hamming_numbers.begin(), hamming_numbers.end());

	//print_vi(hamming_numbers);

	while (cin >> m >> n)
	{
		cout << distance(lower_bound(hamming_numbers.begin(), hamming_numbers.end(), m), upper_bound(hamming_numbers.begin(), hamming_numbers.end(), n)) << endl;
	}
}

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

int main(){
	bool isHamming[1000001];
	int n,m;
	for(int i = 0; i < 1000001; i++){
		isHamming[i]=false;
	}
	for(int i = 1; i < 1000001; i *= 2){
		for(int j = i; j < 1000001; j *= 3){
			for(int k = j; k < 1000001; k *= 5){
				isHamming[k] = true;
			}
		}
	}
	while(true){
		cin >> n;
		if(cin.eof() || n == 0){
			break;
		}
		cin >> m;
		int c=0;
		for(int i = n; i <= m; i++){
			if(isHamming[i])
				c++;
		}
		cout << c << endl;
	}
	return 0;
}