This code initially states that n=10 and f=n. Once the code enters the while loop, it stays in the while loop until the condition n>1 is not true. n is subtracted by 1 every iteration. This means that f = 10*9*8*7*6*4*3*2*1. With 9,8,7,6,5,4,3,2, and 1 being repeated n values. The disp (f) command displays the value of f after the while loop, which is equal to (n!).

Respuesta :

Answer:

  1. n = 10;
  2. f = n;
  3. while(n > 1)
  4.    n = n - 1;
  5.    f = f * n;
  6. end
  7. disp(f);

Explanation:

The solution code is written in Matlab.

Firstly, we initialize n to 10 and set n to f variable (Line 1-2).

Next, create a while loop that will continue to loop until n is equal or smaller than one. In the loop, decrement n by one and multiply n with current f_variable.

At last display value of f. The output is  3628800.

ACCESS MORE
EDU ACCESS
Universidad de Mexico