Generate and Test Solution to Hamming's Problem

#include < stdio.h >
#include < limits.h >

/* Use define to make changing the variable size easy */

#define N 10
#define TYPE unsigned long
#define LIMIT ULONG_MAX
#define FORMAT "%ld\n"

int main()
{
   TYPE p[N];    /* Array of primes */
   TYPE n;       /* Number of elements in p */
   TYPE c,i;     /* Possibilities */
   int k;        /* temp variables */

   /* Primes must be ordered smallest to largest */
   n = 3;
   p[0] = 3;
   p[1] = 5;
   p[2] = 11;

   /* Here is the fun part */
   for(i=2; i < LIMIT; i++)
   {
      c = i;
      for(k=0 ; k < n && c != 1 ; k++)
         while((c % p[k]) == 0 && c != 1 && p[k] <= c) c = c / p[k];
      if (c == 1) printf(FORMAT,i);
   }
   return 0;
}