Thank you for your answers. I tried to "code" the little piece of pseudo-code I posted before and it turns out that's all it is to it! It's solved, it works!!

So my code now is:

Code:

void decomposicao ( int n) {
double sqrt_n = sqrt (n);
int i = 2;
int count;
while (n > 1 && i <= sqrt_n) {
if (n % i == 0){
printf ("%d ^ ", i);
count = 1;
n = n / i;
while (n % i == 0) {
count = count + 1;
n = n / i;
}
printf ("%d * ", count);
}
i = i + 1;
}
}

As I said I couldn't use "for" loops in this assignment. I've learned them (and by the I don't understand what's the advantage in comparison with "while" loops) but I couldn't yet use them.

I just have two more questions, now that it works. I need to understand what the program is doing. So can anyone explain me:

1) how does the program know which factors are primes and which aren't??

2) what is that square root doing there??

(i think these two questions are basically the same but I'm not sure... :P)