It won't work correctly for n greater than 10. :-)
ans-7*(ans>10) would fix that.
You are right, you could use ind2sub to avoid some of the limitations of dec2base as well (e.g. for n>36)...
Find the longest sequence of 1's in a binary sequence.
3430 Solvers
95 Solvers
Getting the indices from a matrice
368 Solvers
Lychrel Number Test (Inspired by Project Euler Problem 55)
60 Solvers
114 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!