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

Solve x^2 + 6x = 24. a. −3 ± square root 21 b. −3 ± square root 34 c. −3 ± square root 15 d. −3 ± square root 33
être malin comme.... A,malin ...... consigne trouve 2 proverbes évoquant la ruse
225% as a fraction equivalent
Explain how the cultural scripts of interdependent cultures might differ from those of individualistic cultures.
Society is always taken by surprise at any new example of common sense
how can you tell isotopes apart?
How do I do this question? 16m + 35 =3
What was known as the Golden Age of India?
What are the resources used to produce the things that humans need and want called? a. capital resources b. human resources c. natural resources d. industri
What is the cube root of 0.008? A) 2 B) 0.2 C) 0.02 D) 0.002