Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How can a teacher answer this ?

3 ビュー (過去 30 日間)
Emma Swaggy
Emma Swaggy 2017 年 5 月 22 日
コメント済み: Thomas Nguyen 2018 年 4 月 8 日
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 件のコメント
Thomas Nguyen
Thomas Nguyen 2018 年 4 月 8 日
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()

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by