Code:
```int   Factorial (  int   number )
//   Pre:   number is assigned and  number >= 0.
{
if  ( number == 0)			//  base case
return  1 ;
else					// general case

return  (number * Factorial ( number - 1 ));
}```
please Switch if statment to for loop

2. Oh come one... you can figure that out for yourself... can't you?

3. For asking a "quick help" you can get a quick ignore.

What are you having problem with? Do you know what this code does?

Code:
```unsigned int Factorial(unsigned int number)
{
unsigned int x = 1;
for (unsigned int i = 2; i <= number; i++)
{
x *= i;
}
return x;
}```

4. I figured that and I get theis :

Code:
```
int fac(int i)
{
int ret = 1;
for(;i>1;--i)
ret *= i;
return ret;
}```

5. Originally Posted by kmdv
For asking a "quick help" you can only get a quick ignore.

Whata re you having problem with? Do you know what this code does?

Code:
```unsigned int Factorial(unsigned int number)
{
unsigned int x = 1;
for (unsigned int i = 2; i <= number; i++)
{
x *= i;
}
return x;
}```

Thanx, you are very cool
I'm only a beginner

6. It's correct and I guess it wasn't that hard. Next time you should post your results along with the assignment.

7. my code is correct? or what

8. Next time you should post your results along with the assignment.
Out of curiosity, if that is the way you feel, why did you do it for him this time?

Soma

is it true ?

10. O_o

If you know that the recursive version is correct, why don't you just compare the results of both versions up to 12 or 13 or so?

Soma

11. Originally Posted by phantomotap
Out of curiosity, if that is the way you feel, why did you do it for him this time?
I did not want to see next thread with a simple question, dragging on forever, instructing the newcomer how he should ask questions the smart way. Anyway, I did not avoid it, cuz it already reaches the 10th reply.

Originally Posted by Needle_Scratch
is it true ?
Yes, both are "true", I wouldn't post false code.