Skip to content

Commit

Permalink
Had to learn GDB basics to solve this one.
Browse files Browse the repository at this point in the history
  • Loading branch information
mblair committed Oct 12, 2010
1 parent af13b02 commit 3dcaae0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions ch1/exercises/ex8.c
@@ -0,0 +1,28 @@
#include <stdio.h>

int main(void) {
int input, i = 0;

printf("Please enter a positive integer: ");
fflush(stdout);
scanf("%d", &input);


while (input > 1) {
for(i=2; i <= input; i++) {
if(input % i == 0) {
if (input / i == 1) {
printf("%d\n", i);
} else {
printf("%d * ", i);
}
fflush(stdout);
input /= i;
break;
}
}
}


return 0;
}

0 comments on commit 3dcaae0

Please sign in to comment.