0

I posted this thread but it got transferred to another, can someone edit the code for me so that I can get the answer in exponentiation, (^)and(*),

Example :

Enter number : 8

Prime factors of '8' : 2^3

Enter number : 56

Prime factors of '56' : 2^3*7

Not

Enter number : 8

Prime factors of '8' : 2*2*2

Enter number : 56

Prime factors of '56' : 2*2*2*7

This can really save lots of trouble. Please help me with this, Thanks!

```
#include <stdio.h>
/* Find out the prime factors
* of a given number and print
* them on the screen */
void factorize(int n)
{
int d = 2;
if(n < 2) return;
printf("Prime factors of '%d': ", n);
/* while the factor being tested
* is lower than the number to factorize */
while(d < n) {
/* valid prime factor */
if(n % d == 0) {
printf("%d * ", d);
n /= d;
}
/* invalid prime factor */
else {
if(d == 2) d = 3;
else d += 2;
}
}
/* print last prime factor */
printf("%d\n", d);
}
#if defined TEST_DRIVER && TEST_DRIVER > 0
void factorize_test(void)
{
int i;
for(i = 0; i < 50; i++) {
factorize(i);
}
}
int main(void)
{
factorize_test();
return 0;
}
#else
int main(void)
{
int number;
do {
printf("Enter number: ");
scanf("%d", &number);
factorize(number);
} while (number > 1);
return 0;
}
#endif
```