Correct idea. But take care of the overflow. This sequence just explodes at high values of n. Try enhancing the modular arithmetic in it.
I didn't expected the recursion to work because of it's exponential time complexity O(3^(n-3)). But it worked :O.
Nicely written code. ^_^
Make a run-length companion vector
524 Solvers
Square Digits Number Chain Terminal Value (Inspired by Project Euler Problem 92)
172 Solvers
Approximation of Pi (vector inputs)
92 Solvers
243 Solvers
142 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!