Originally posted by MikeH
hc_grove,
I don't see this program or the source on the linked page. If it's still available (in particular the source) I'd be very interested. Thanks.
I don't remember if it's susposed to be available on the page, but here's the source.
Code:
/* Written by Henrik Christian Grove */
/* Released as beerware */
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
unsigned long long number;
char *endptr[10];
unsigned long div = 2;
unsigned int exp = 0;
if (argc != 2) {
printf("Error!\n");
exit(-1);
}
number = strtoll(argv[1],endptr,10);
if ((number % 2) == 1) {
number--;
}
printf("Factoring %llu\n",number);
printf("%llu = ",number);
while ((number % 2) == 0) {
exp++;
number /= 2;
}
if (exp > 1) {
printf("2^%u*",exp);
} else {
printf("2*");
}
div = 3;
while (div < number) {
exp = 0;
while ((number % div) == 0) {
exp++;
number /= div;
}
switch (exp) {
case 0:
break;
case 1:
printf("%lu*",div);
break;
default:
printf("%lu^%u*",div,exp);
}
div +=2;
}
printf("%llu\n",number);
exit(0);
}