Info

This question is closed. Reopen it to edit or answer.

Hello, all! I just had a quick question about this short script for finding the factorial of any integer. But now I need to find the factorial of an array of vectors, and it won't work for more than 1 value at a time. Any thoughts?

1 view (last 30 days)
Num = input('Input a number to find its factorial: ');
k = 1;
if Num >= 0
for i = 1:Num
k = k*i;
end
else
error('Cannot compute a negative factorial')
end

Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!