- Can you create a vector of length x? I hope so.
- Can you sum all the elements in a vector? Again, if you cannot, then did you fall asleep in class that month?
- Can you now create a NEW vector, that contains elements 2:x of the vector, and then append the sum you formed in step 2?
- Can you iterate steps 2:3 until you are done? Hint, what does a loop do?
How to display the nth term where the nth term is found by adding x number previous term?
3 ビュー (過去 30 日間)
古いコメントを表示
I am trying to write code that will ask the user to input n and x. The sequence is similar to the fibonacci sequence, but instead of adding the previous 2 terms, I want to find the next term by adding the previous x number of terms. I then want it to display the nth term of this sequence, also inputted by the user.
0 件のコメント
回答 (1 件)
John D'Errico
2021 年 8 月 19 日
Admit it. This is homework, since nobody would ask you to do this if it were not. And since it is homework, NOBODY should write the code for you. It is YOUR homework.
But I'll give you some hints.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!