Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

How can a teacher answer this ?

3 vues (au cours des 30 derniers jours)
Emma Swaggy
Emma Swaggy le 22 Mai 2017
Commenté : Thomas Nguyen le 8 Avr 2018
Write a program that will display the result of n! using a loop. For example, if the user enters 5 for n, the program should display “factorial of is 120”.
  1 commentaire
Thomas Nguyen
Thomas Nguyen le 8 Avr 2018
function[] = factorial()
n=input('Enter value n: ');
fac=1;
for i=1:n
fac=fac*i;
end
disp(['The factorial of ',num2str(n),' is: ',num2str(fac)])
end%factorial()

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by