I suppose k and m must be non-negative integers, or else all integers can be written in this way.
First note that .
Write where or 2. Note that .
Clearly if you are done.
Now to make sure just check all cases up to k=6 but you already did that.