create function that performs the following computation

S=N = 1+1/2+1/3+1/4+.........1/N
Σ
K =1

1 件のコメント

Anusha Sridharan
Anusha Sridharan 2018 年 12 月 27 日
[Answers Dev] Restored Edits

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 10 月 3 日

0 投票

function sum_result=sum1(n)
sum1=0;
for i=1:n
sum1=sum1+1/n;
end
end
Same can be done by using while loop also. It someone using indexing, it would be better.\
Learn Matlab by doing

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

タグ

質問済み:

2018 年 10 月 3 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by