필터 지우기
필터 지우기

can anyone know to write a mathlab function that takes an input integer "n" and computes the following

조회 수: 2 (최근 30일)
Capture 3333.PNG

답변 (1개)

Prasanth Sikakollu
Prasanth Sikakollu 2019년 6월 10일
Using While loop, try the following function:
function result = getFacWhile(n)
result = 1;
while n ~= 1
result = result * n;
n = n - 1;
end
end
Using for loop, try the following function:
function result = getFacWFor(n)
result = 1;
for i = 2:n
result = result * i;
end
end
Hope this helps
  댓글 수: 1
Steven Lord
Steven Lord 2019년 6월 10일
Please don't post solutions to homework problems (or problems that sound like they're probably homework problems) unless the person asking the question has shown the effort they've put in place first.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by