Write a positive whole number as a product of primes, like 90=2*3*3*5, or 97=97 (a prime is just itself). Finish factor(n): from 2 up, if it divides, show that factor and divide n by it. The starter shows 90=; sep goes before each factor: nothing first, then *. The program factors 90, 100, 97.
90=2*3*3*5 100=2*2*5*5 97=97
#include <stdio.h>
void factor(int n) {
printf("%d=", n);
const char *sep = "";
for (int i = 2; i <= n; i++) {
// your code here: while i divides n, show i, then divide n by i
}
printf("\n");
}
int main(void) {
factor(90);
factor(100);
factor(97);
return 0;
}
Run tries the examples. When they look right, Submit.