// // sof -- Compute sum of factors. // // 10-Sep-2010 tvb www.LeapSecond.com/tools // #include #include void main (int argc, char *argv[]) { long n, f, sof; n = (argc > 1) ? atol(argv[1]) : 496; sof = 0; for (f = 1; f <= n / 2; f += 1) { if ((n % f) == 0) { printf("%10ld * %ld\n", f, n / f); sof += f; } } printf("sof(%ld) = %ld, %s\n", n, sof, (sof == 1) ? "prime" : (sof == n) ? "perfect" : (sof < n) ? "deficient" : "abundant"); }