using the while loop function
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (1)
Akshay Kanoria
am 7 Okt. 2013
1 Stimme
Hi, Inside the loop you should use n = n-1, it should solve your problem.
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!