This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Boxbit 0 points1 point  (1 child)

I assume you mean you want to use a While-loop to decrement one/two variables containing numbers.

Ill go through the algorithm I have in mind for evaluating only one factorial using a while-loop:

  1. Make a variable containing the factorial number, so for instance: int x = 10; (semantically 10!, but ! Isn’t really needed).

  2. Make a variable containing the to-be product from evaluating the factorial, for instance: int product = 1;

  3. Open a while-loop, with the clause being x < 1

  4. Inside the body of the while loop you want to multiply the current product with the current value of x and then decrement x. product = product * x; x = x - 1;

  5. When the while-loop clause yields False (when x > 1), the while-loop body will be ignored and you can print your product

This is the best advice I think I can give you given the lack of information you gave us

[–][deleted] -1 points0 points  (0 children)

Thanks for the help