Using a conditional while loop in MATLAB find the first fact
Using a conditional while loop in MATLAB, find the first factorial that is greater than the input argument high. (high= 5000)
Solution
% matlab code determine first factorial greater than input argument
high = input(\"Enter input argument high: \");
fact = 1;
number = 2;
while fact <= high
fact = fact * number;
number = number + 1;
end
fprintf(\"%d! = %d is the first factorial greater that %d\ \",number-1,fact,high);
%{
output:
Enter input argument high: 5000
7! = 5040 is the first factorial greater that 5000
%}
