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. ^_^
2486 Solvers
352 Solvers
Combined Ages 1 - Symmetric, n = 3
107 Solvers
Matrix of almost all zeros, except for main diagonal
152 Solvers
63 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!