Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Factorial Problems involving repeition

1 回表示 (過去 30 日間)
hBk
hBk 2013 年 9 月 17 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hello, i have a little and maybe simple problem here..can somebody help me to solve my problem.. i appreciate it.. How to write a matlab code for factorial problem. for example;
E= 1!+2!+3!+....... until the calculation stops at 153. The program also gives/display how many times it has to do the addition until it get to 153.
  1 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 9 月 17 日
What have you tried so far?

回答 (1 件)

Yatin
Yatin 2013 年 10 月 16 日
編集済み: Yatin 2013 年 10 月 16 日
Hi,
Below is the code. The value of " count " is the number of times the sum was carried out.
addition = 0;
count = 0;
oldFact = 1;
while(addition < 153)
newFact = (count+1)*oldFact;
addition = addition + newFact;
oldFact = newFact;
count = count+1;
end

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by