1 /* factor - print the prime factors of a number Author: Andy Tanenbaum */
6 int main(int argc
, char **argv
);
17 if (argc
!= 2 || (n
= atol(argv
[1])) < 2) {
18 printf("Usage: factor n (2 <= n < 2**31)\n");
22 printf("2 is a prime\n");
29 printf("%ld is a prime\n", n
);
44 /* Return the first factor of k. If it is a prime, return 0; */
48 if (k
== 2) return(0);
49 if (k
% 2 == 0) return (2);
50 for (i
= 3; i
<= k
/ 3; i
+= 2)
51 if (k
% i
== 0) return(i
);