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

Is this right? Domain and range. Also what about the graph. Thank you
What does it mean for a law to be just
what was true about the deportation of mexican americans during the great depression
Marvin wrote a check of $58.25 for the water bill and $450 for rent. he also made a deposit of $124.16. how much is his new balance after writing the checks and
Matt has a mass of 37 kg and skis down a hill with no friction or air resistance. The hill has an angle of 24 degrees. The free-body diagram is show below. a.
When a functional structure is combined with a project structure, the resulting structure is called a(n)_structure
What tool can a student use to make sure his or her paper does not inadvertently take credit for someone else's work
A rock is dropped and falls freely at 100 meters to Earth. What is the speed of the object after 4 seconds?​
Santiago rides his bicycle at a rate of 6 kilometers every 15 minutes at that same rate how many kilometers can Santiago ride in 25 minutes ( Has To Do With Pro
First to answer gets brainliest! The central part of an atom is the _______. A nucleus B neutron C proton D molecule