Generate the first k terms in the sequence a(n) define recursively by
a(n+1)=p*a(n)+(1+a(n)) with p=0.9 and a(1)=0.5
Test Case
n = 2;
a = [a(1) a(2)] = [0.5000 1.9500]
Solution Stats
Problem Comments
6 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers45
Suggested Problems
-
6435 Solvers
-
313 Solvers
-
Magic is simple (for beginners)
11108 Solvers
-
Is this triangle right-angled?
6385 Solvers
-
Matlab Basics - Switching Assignments
502 Solvers
More from this Author3
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
The difficulty with this problem is not generating the sequence, that is trivial, but to conform to the completely arbitrary and inaccurate rounding rules of the test suite.
Something I really want to tell the one who create this problem: base on this test suite you just made, I'm positively sure that you've learned your lesson in gym class.
Need to round the results to 4 decimal places, and for one of the cases multiply by 1e5*round(out/1e5,4). I am pretty sure the author ran the function and just copied and pasted its result in the test suite. Not a good idea for single or double numbers. The test suite needs some tolerance to error due to numeric imprecision.
Tolerance has been added to the test suite, in addition to removing a problematic case.
Unrecognized function or variable 'tolerance'.
I have updated the test suite to manually check the tolerance.
I find it weird that the way Grant defined tolerance as a variable and
used it for individual test cases works fine for some solutions but doesn't for other solutions. And this particular error has occurred on other problems as well.