Theory
A function machine starts with an input, follows one or more operations, and gives an output. For example, 'multiply by 3, then add 2' sends input 4 to output 14.
The order matters. 'Multiply by 3 then add 2' is 3x + 2. 'Add 2 then multiply by 3' is 3(x + 2), which is different.
To work backwards from an output, undo the operations in reverse order. For 3x + 2 = 17, first subtract 2, then divide by 3 to get x = 5.
A letter can describe any input. If the rule is double then subtract 1, the output is 2x - 1. This connects function machines to forming expressions and solving equations.
Check your answer by putting the recovered input through the original machine. If it does not produce the given output, revisit the order of operations.