to see the source of this problem and the solution:

it's an old book of mathematic that i've found on Gutenberg Project., **
page-17**

A Scrap-Book of Elementary Mathematics: Notes, Recreations, Essays by White

**A person privately ﬁxing on any number, to tell him that number. **

After the person has ﬁxed on a number, bid him double it and add 4 to that sum,

then multiply the whole by 5; to the product let him add 12, and multiply the amount by 10.

From the sum of the whole let him deduct 320, and tell you the remainder,

Now create a program to find the mysterious number ?

and the general math formula behind it !

Here is the book where i found this: