program that calculates how many terms it takes

2 ビュー (過去 30 日間)
Rand Renwar
Rand Renwar 2016 年 2 月 3 日
コメント済み: Image Analyst 2016 年 2 月 4 日
So I'm supposed to write a program that calculates how many terms it takes for (1/1)+(1/2)+(1/3)+(1/4)...(1/n) shall be more than 4.
I can't use matlabs built-in functions (sum, sorting). Thank you!
  5 件のコメント
the cyclist
the cyclist 2016 年 2 月 3 日
When someone is in a course, and they feel they have no idea how to even get started on their homework, my advice is to go to the teacher as soon as possible and have a frank discussion about their situation.
Rand Renwar
Rand Renwar 2016 年 2 月 3 日
I will tomorrow, but we started this course last week :) And i've got like 2 weeks left until deadline, but I want to do it as soon as possible :)

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

採用された回答

Star Strider
Star Strider 2016 年 2 月 3 日
What about my Answer to your previous Question on this exact topic did not work for you? See Never approached this kind of program before, need help..
  3 件のコメント
Star Strider
Star Strider 2016 年 2 月 4 日
My pleasure!
Image Analyst
Image Analyst 2016 年 2 月 4 日
Rand, up at the top of the screen, you can find all your questions from My MATLAB Answers:

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2016 年 2 月 3 日
編集済み: Image Analyst 2016 年 2 月 3 日
Use a for loop or a while loop. If using a for loop, put an "if" test in there to see if it's more than 4 and then "break" if it is. If using a while loop, then the test for >4 is part of the while statement.
Don't use sum for a variable name - use something like theSum instead since sum() is a built in function
theSum = theSum + 1/...........
Good luck!

カテゴリ

Help Center および File ExchangeUtilities for the Solver についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by