Question

Write a MATLAB script, using either a single or nested for-loop, that will print the factorials...

Write a MATLAB script, using either a single or nested for-loop, that will print the factorials for the numbers between 1 and 100 (inclusive). The factorial of n (n!) is the product of the positive integers less than or equal to n. For example: 3! = 3 * 2 * 1. For this question you cannot use the built-in MATLAB factorial function, but you can use other MATLAB functions if you wish.

MATLAB code!MATLAB code!MATLAB code!MATLAB code!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

code:

num1=input("Enter first number:"); % taking input initial value
num2=input("Enter last number:"); % taking input ending value
n=1; % initializing n
for i=num1:num2
n=n*i; % calculating factorial
fprintf("%d\n",n); % printing factorial
end

output:

code screenshot:

Note: Please refer code screenshot for indentation of code.

Add a comment
Know the answer?
Add Answer to:
Write a MATLAB script, using either a single or nested for-loop, that will print the factorials...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT