You can make it with DP if you're observant enough and make enough tables to look at. (That's how I initially solved this kata. Though OEIS and other previous experiences of sequences also helped.)
I found same solution after a long time. I think the label "DYNAMIC PROGRAMMING" is kind of confusing.
All the solutions in python are the same way.
maybe the label "math" or something else is better?
Well, you can use memoization on this kata (Not the linear version though), so DP is a valid tag.
I guess I can add the mathematics tag to the kata.
Edit: Done
You can make it with DP if you're observant enough and make enough tables to look at. (That's how I initially solved this kata. Though OEIS and other previous experiences of sequences also helped.)
The more performance heavy linear version, though, actually requires mathematics.
I found same solution after a long time. I think the label "DYNAMIC PROGRAMMING" is kind of confusing.
All the solutions in python are the same way.
maybe the label "math" or something else is better?
I think the label "DYNAMIC PROGRAMMING" is improper. I can't make it with DP.
In fact I think it is more like a math problem.
I don't know whether the reason is that I use python so I can't make it with DP.