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

What is the compound subject in this sentence? Yellow and black are my favorite colors. OA. favorite colors OB. yellow and black Oc. yellow D. are my favorite O
!!NEED HELP QUICKLY PLEASE!!True or False: 1a) People live longer in Puerto Rico than in Afghanistan 1b) Puerto Rico is growing rapidly
An amoeba is a unicellular organism, which doesn’t have a stomach for digestion of food. How does food storage and digestion take place in an amoeba?
What is the meaning ofmoney​
Which of the following statements most accurately describes recent psychological research on the concept of narcissism?
why is it challenging to write about people you know? Give an example to support your answer.
A heavy copper ball of mass 2 kg is dropped from a fiftieth-floor apartment window. Another one with mass 1 kg is dropped immediately after 1 second. Air resist
The system {y=2,y=-3}
TRUE OR FALSE Specific Performance is often a remedy when one party fails or refuses to work for another.
What was the name of th first English settlement in new England