I have the numbers 1 - 100, when they are put into a box (an abstracted code function I do not know the details of), they come out as
0 = 1
1 = 4
2 = 6
3 = 9
4 = 11
5 = 14
6 = 16
7 = 19
8 = 21
9 = 24
10 = 26
11 = 29
12 = 31
13 = 34
14 = 36
15 = 39
16 = 41
17 = 44
18 = 47
19 = 49
20 = 52
21 = 54
22 = 57
23 = 59
24 = 62
25 = 64
26 = 67
...
100 = 254
I know the range that comes out of the box (code) is 1-254 .. If someone can help me unravel reversing the equation this uses, that would be amazing
ie original output of the code produces 4 when it is given 1. I want to give my code 4 and get back 1
convert(output);
value = convert(4);
# value would be 1; etc
The differences (seem to) alternate between $2$ and $3$. That means the odd and even positions each form an arithmetic progression with difference $5$.
That should be enough information for you to reconstruct the
convertfunction. There's no really clean "formula".Edit in answer to comments. The following algorithm correctly makes the calculation based on the previous observation, but that observation does not match the data. The comments explain what's going on.
The output number $y$ will always leave a remainder $r$ of $1$ or $4$ when you divide it by $5$. To recover the input $x$:
Let $$ z = \frac{(y-r)}{5}. $$ Then $$ x = \begin{cases} 2z & \text{ if } r = 1 \\ 2z+ 1 & \text{ if } r = 4 . \end{cases} $$