using the while loop function
显示 更早的评论
I am new to MATLAB and trying to use a while function and not understanding why there is no error, but keeps the system busy with no result.
function fac=fact(n);
fac=1;
while n>0
fac=fac*n;
n-1;
end
采纳的回答
更多回答(1 个)
Akshay Kanoria
2013-10-7
1 个投票
Hi, Inside the loop you should use n = n-1, it should solve your problem.
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!