Using a "while" loop to calculate a factorial

Use a while loop to calculate f=10!. Display only the final value using the function "disp"

2 comentarios

James Tursa
James Tursa el 20 de Feb. de 2021
What have you done so far? What specific problems are you having with your code?
I figured it out! Thanks though!

Iniciar sesión para comentar.

 Respuesta aceptada

Kate Heidingsfelder
Kate Heidingsfelder el 20 de Feb. de 2021
kk = 10;
k = 1;
f = 1;
while k <= kk
f = k * f;
k = k + 1;
end
format long
disp(f)

Más respuestas (2)

Anusha
Anusha el 25 de Oct. de 2023

0 votos

kk = 10;
k = 1;
f = 1;
while k <= kk
f = k * f;
k = k + 1;
end
format long
disp(f)
Anusha
Anusha el 25 de Oct. de 2023

0 votos

kk = 10;
k = 1;
f = 1;
while k <= kk
f = k * f;
k = k + 1;
end
format long
disp(f)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Productos

Versión

R2020b

Preguntada:

el 20 de Feb. de 2021

Respondida:

el 25 de Oct. de 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by