#include <math.h>
#include <stdio.h>
#include <stdlib.h>

#ifdef USE_INT

  typedef long            NUMBER;

  #define DIVIDES(x,y)    (((y) % (x)) == 0)
  #define FORMAT          "%d"
  #define atonumber       atoi
#else

  typedef double          NUMBER;

  #define DIVIDES(x,y)    (fmod(y,x) == 0)
  #define FORMAT          "%.0lf"
  #define atonumber       atof
#endif

void factor(NUMBER x)
{
   int n,limit;
   while (DIVIDES(2,x)) {
      printf("2 ");
      x /= 2;
   }
   limit = ceil(sqrt(x));
   for (n=3; n <= limit; n += 2) {
      while (DIVIDES(n,x)) {
         printf("%d ", n);
         x /= n;
         limit = ceil(sqrt(x));
      }
   }

   if (x > 1)
      printf(FORMAT, x);

   printf("\n");
}

int main(int argc, char **argv)
{
   NUMBER x;
   if (argc < 2 || (x = atonumber(argv[1])) < 1) {
      printf("Ouch!\n");
      return 1;
   }

   printf(FORMAT ": ", x);

   factor(x);

   return 0;
}
