フィルターのクリア

Perform a program that shows the series 1!/2!, 2!/3!, 3!/4!, .....

3 ビュー (過去 30 日間)
Chroma Prime
Chroma Prime 2018 年 10 月 26 日
回答済み: Stephen23 2018 年 10 月 28 日
Perform a program that shows the series 1!/2!, 2!,/3!, 3!/4!, .....
  1 件のコメント
per isakson
per isakson 2018 年 10 月 28 日
What about
>> 1./(2:17)
ans =
Columns 1 through 8
0.5000 0.3333 0.2500 0.2000 0.1667 0.1429 0.1250 0.1111
Columns 9 through 16
0.1000 0.0909 0.0833 0.0769 0.0714 0.0667 0.0625 0.0588
>>

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

回答 (2 件)

madhan ravi
madhan ravi 2018 年 10 月 28 日
編集済み: madhan ravi 2018 年 10 月 28 日
1) Create n as an input.
2) Make a loop until n .
3) Declare a variable named n_series with loop iterator as an index.
4) Declaration would be ...
factorial(i-1)/factorial(i) %i -Loop iterator
5) End the loop.
"If you follow the above steps and stitch them together" , you will be able to finish your homework easily.

Stephen23
Stephen23 2018 年 10 月 28 日
A loop is not required, simple vectorized code will do this:
>> V = factorial(1:11);
>> V(1:10)./V(2:11)
ans =
0.500000 0.333333 0.250000 0.200000 0.166667 0.142857 0.125000 0.111111 0.100000 0.090909
>> 1./(2:11) % get rid of the factorials, same results.
ans =
0.500000 0.333333 0.250000 0.200000 0.166667 0.142857 0.125000 0.111111 0.100000 0.090909

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by