terrifunk7546 terrifunk7546
  • 22-09-2017
  • Computers and Technology
contestada

Write a program that lets a user enter n and that outputs n! (meaning n*(n-1)*(n-2)*...*2*1). hint: initialize a variable totalvalue to n, and use a loop variable i that counts from n-1 down to 1.

Respuesta :

Аноним Аноним
  • 30-09-2017
//  This code snippet calculates n! and stores the answer in the variable p.
// Handle 0! = 1 separately.
if (n==0) {
   p = 1;
}
else {
// Initialize p = n
p = n;

// While loop
while (n>1) {
      p = p*(n-1);
      n = n-1;
     }
}

Answer Link

Otras preguntas

Accuracy is how _______ a measurement is to the expected value'
describe what the tissue/cell looks like
Which of the following is an example of the limited role of government in the economy
What is the radius of the circle? Example how you know..
This question makes literally no sense PLEASE HELP
What is the largest integer that is below square root of 28?
Describe typical play activities for boys and girls. Use the theories of social development to explain why these play styles are typical.​
The ratio of the areas of two right isosceles triangles are in the 16.25 Calculate the ratio of their corresponding heights.
While speed walking to class, a college student clumsily swings his ankles too close together, so they end up hitting at the medial projections. What specific s
What's effect of unintentional injury and violence on a person physically​