TASK: Create a version of the Fibonacci sequence that adds the last three values.
COMMENT: To get the next Fibonacci number, we add the two previous ones, and we start with values 1 and 1.
Consider a new rule, in which the next number is determined by adding the three previous values, and we start with 1, 1, and 1.
INSTRUCTIONS:
We need to have four variable names. One possibility is to use "f1", "f2", "f3" and "f4", where "f4" will be our next value. Before we begin, set f2, f3, and f4 to 1. Create a for loop that counts from 1 to 10. We can use "i" for the counter variable. copy the value of f2 into f1 copy the value of f3 into f2 copy the value of f4 int f3 compute the new value of f4 fprintf ( ' %d + %d + %d = %d\n', f1, f2, f3, f4 ); end your FOR loop
SUBMIT: Your work should be stored in a script file called "hw019.m". Your script file should begin with at least three comment lines:
% hw019.m % YOUR NAME % This script (describe what it does) % Add any comments here that you care to make.If this problem is part of an assignment, then submit it to Canvas.