Quote:

> Just having fun with VC++ here, man it's fun. I have a problem that I'm

> trying to solve. It is possible to do it without a loop, but I want to do it

> with a loop or loops, so there is less code.

> Here it is:

> The factorial of an integer "n", written "n!", is the product of the

> consecutive integers 1 through "n". For example, 5 factorial is calculated

> as:

> 5! = 5 * 4 * 3 * 2 * 1= 120

> I'm trying to figure out how to use a loop or loops to do this. So they will

> generate and print a table of the first 10 factorials. I don't know if I'm

> looking at this too hard and it's very easy or it may be hard to do with

> loops.Not to sure here..I am writing this in "C" though.

You really should just get a book on the language. This newsgroup

exists to help you after you've exhausted the most basic resources -

your brain, a book, a friend, and the FAQ.

This problem isn't really all that difficult. Try writing some

pseudo-code first to see if you can figure out the principle behind the

calculations, and if you get that right then translate it into C code.

For example, my pseudo-code for calculating a factorial would look like:

result = 1

for i = 1 to number

result = result * i

(This is a very simple and incomplete definition of a factorial, but

there's no need to make it more complicated than you need.)

Try posting some C code, even if it doesn't work. We're more inclined

to help if you've shown a bit of effort, even if you didn't get any

where.

--

I believe we can change anything.

I believe in my dream.

- Joe Satriani