factorial given:
Compute the factorial using a loop for the case of n=7.
Compute n=7 using matlab built-in factorial func.

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 3 月 1 日

0 投票

help factorial
help for

3 件のコメント

Ronald
Ronald 2014 年 3 月 1 日
編集済み: Ronald 2014 年 3 月 1 日
Thank you for your response, however, this is my first class and our workshops are nothing like what is expected in our homework. My issue is creating a script. I am aware of the help in matlab even though my question had nothing to do with that, my problem lies with scripting. I know what I want the program to do, I just do not know how to convey it to the program.... and neither one of your comments address the issue.
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 3 月 1 日
編集済み: Azzi Abdelmalek 2014 年 3 月 1 日
Ok, then what have you done, so we can guide you
Image Analyst
Image Analyst 2014 年 3 月 2 日
The help on factorial says "f = factorial(n) returns the product of all positive integers less than or equal to n, where n is a nonnegative integer value." so how can you say that Azzi's answer does not address your issue when right there in the help is an example that is the answer to your question????? Same thing for the for loop - it tells you how to do a for loop and all you have to do is to put one line in the middle of it. It's your homework so he's not going to do 100% of it but it would be hard to give you code that doesn't do 100% for you when the code is so incredibly short.
nFactorial = 1
for i = 1 : n
nFactorial = ..... you do this
end
The for is described in the help like he referred you to, and if I do just a few characters more, then I've done the whole thing for you and you'd be turning in my solution instead of yours.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

質問済み:

2014 年 3 月 1 日

コメント済み:

2014 年 3 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by