Factor
Factor
Factor
h>
int main(int argc, char** argv) {
int i, num, isPrime = 1;
if(argc != 2) {
printf("This program takes one argument of type integer.\n\n");
exit(-1);
}
sscanf(argv[1], "%d", &num);
printf("Factors of %d: \n", num);
printf("1, ");
for(i = 2; i < num; i++) {
if(num % i == 0) {
printf("%d, ", i);
isPrime = 0;
}
}
printf("%d\n", num);
if(isPrime == 1) {
printf("%d is prime.\n", num);
}
return 0;
}