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

Triangles ABC and DEF are similar triangles. What are the lengths of the unknown sides? A) DF = 39 cm; DE = 15 cm B) DF = 48 cm; DE = 52 cm C) DF = 65 cm; DE
I NEED MAJOR HELP WITH THIS QUESTION Instriction; using the following image, solve for tbe trigonometry ratios of < D and < F .​
Hello:) how to do question 6? :) I’m not sure which property to use :/
Ursula has a new team member, Tom, who came from another worksite. Tom is constantly trying to make new suggestions and explain how things used to work his old
Liberia was established in 1847 by freed slaves from the United States. Please select the best answer from the choices provided T F
find the value of trigonometric ratio​
Can someone help me please
I need help make sure to round it to the nearest 10th
which of these events happened last?​
Our records that your account is overdue.