I have written a piece of code to do as the title says, but I seem to have a problem in that any odd number of digits is converted wrong. eg. it converts 25 correctly but not 125.
it gives me 1 less than the value I expect, output is 124 for input of "125"
Here is my code, can anyone see any mistakes I've been looking over it for ages now and can't figure it out.