MATLAB: Convert for loop to while for loopMATLAB Online Serverwhile loop how can i convert this n=5;fact = 1 ;for i = 1:n fact =fact * i;end;disp(fact) into while loop with my best regards Best Answer i = 1 ; f = 1 ;n = 3 ; while i<=n f=f*i; i = i+1 ; end Related SolutionsMATLAB: Write M file with while loop, which computes factorial of any x, (x=12). You need to update the value of factorial at each step by using its value from the previous stepx=12;fact = 1;while x>1 fact = fact*x; x=x-1;enddisp(fact); MATLAB: For and while loops function F = getFacWhile(n) F=1; while n>1 F=F*n; n=n-1; endendfunction F = getFacWhile(n) F=1; for i=1:n F=F*i; endend Related QuestionNeed helping finding the source of the forever loop in the codeHow to convert this for if loop into a while loop
Best Answer