Never approached this kind of program before, need help.

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!

 채택된 답변

Star Strider
Star Strider 2016년 2월 2일

1 개 추천

Use a while loop, and keep track of the accumulating sum in each iteration.

댓글 수: 2

sorry but i don't understand. I am super new to matlab. Could you explain a bit more? Thank you
Best regards Rand Renwar
I was thinking something like this:
series_sum = 0;
k1 = 0;
while series_sum <= 4
k1 = k1 + 1;
series_sum = series_sum + 1/k1;
end

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

2016년 2월 2일

댓글:

2016년 2월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by