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. ^_^
2527 Solvers
979 Solvers
67 Solvers
5813 Solvers
88 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!