#include <stdio.h>
#include <string.h>
int ham_num(int x) {
int h = x;
while (h && (h%2 == 0))
h = h/2;
while (h && (h%3 == 0))
h = h/3;
while (h && (h%5 == 0))
h = h/5;
/*
* h will be 1, when it is ham num, else it will be
* something else - example h =10
*/
return h;
}
int main(int argc, char *argv[])
{
int x = 1, cnt = 20;
printf("Hamming Numbers : \n");
if (argc > 1)
cnt = atoi(argv[1]);
while (cnt) {
if (ham_num(x) == 1) {
printf("%d ",x);
cnt--;
}
x++;
}
printf("\n");
}