Write a matlab m. file using loops to find the first factorial that is larger than an input number
%Copy the code below-
%--------------------------------------------------------------------------------------------------------------------------------
prompt = 'input a number';
num = input(prompt); % Input command for number
prod =1; % defining product variable
for i = 1:num+1 % initiating the loop
prod = prod*i;
if prod>num % comparing value of the product with the input number
break;
end
end
fprintf('%i! ', i) % printing the required value of factorial
%---------------------------------------------------------------------------------------------
Get Answers For Free
Most questions answered within 1 hours.