- 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 views (last 30 days)
Show older comments
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 Comments
Answers (1)
John D'Errico
on 19 Aug 2021
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 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!