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

A person who commits a tort is often referred to as _____________ a. tortfeasor b. guiltfeasor c. criminal d. runaway defendant e. nominal defendant
78 is what percent of 312
if you were going to represent the top view of the figure state which boxes would should be shaded​
1. The most common purpose of a comparison/contrast essay is not to state the obvious but rather to illuminate subtle differences or unexpected similarities. T
Answer please hurry I need the answer
A short, nonsmoking middle-aged man presents to the emergency room with left-sided chest pain and a cough. he says that the pain started abruptly, just after lu
A plot of land is 3/8 mile by 2 1 /4 miles. Spencer solves 3/8⋅2 1/4 to find the area of the land in square miles. Enter numbers to complete Spencer's calcu
Help me on this question
Peanut allergies among children. About 2% of children in the United States are allergic to peanuts. Choose three children at random and let the random variable
Create a linear equation and a linear table of values. Show In you table the linear pattern of adding a constant value repeatedly.