Hi everyone,
I have a vector y2 starting from 1 to 100 with properties of y2(1)=1 and y2(i+1)-y2(i)=i+1
Knowing that i=1,…,99 what it will be y2(100)?
Thank you very much!!!
Best Regards.

 採用された回答

Roger Stafford
Roger Stafford 2014 年 5 月 2 日
編集済み: Image Analyst 2014 年 5 月 2 日

1 投票

If you look at this site in the section called Anecdotes" you will see a short cut to obtaining your answer. It doesn't require matlab at all.

4 件のコメント

Image Analyst
Image Analyst 2014 年 5 月 2 日
I don't get 5050, because in Tamer's situation, the difference between two terms is not 1 but (i+1), so I get a different number. The difference between adjacent numbers increases as the number of terms grows, unless Tamer didn't transcribe it correctly. y2(2) and y2(1) are separated by 1+1 = 2 while y2(100) and y2(99) are separated by 99+1 = 100.
Star Strider
Star Strider 2014 年 5 月 2 日
I do get 5050, rearranging the equation to have y2(i+1) on the LHS, then looping.
Gauss’ ‘shortcut’ solution is brilliant and insightful. But then, so was Gauss.
Strider
Strider 2014 年 5 月 2 日
Hi Star Strider, I am a novice in Matlab, can you please show me what you typed to get the right answer (5050). thanks a lot!!
Image Analyst
Image Analyst 2014 年 5 月 2 日
You're right. I messed up.

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2014 年 5 月 2 日
編集済み: Image Analyst 2014 年 5 月 2 日

0 投票

Why not make a simple for loop and find out?
y2(1)=1;
for i = 1 : 99
y2(i+1) =
and so on.... It's the best way to learn!

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

タグ

質問済み:

2014 年 5 月 1 日

編集済み:

2014 年 5 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by