Finding the equation pattern of a known set

105 Views Asked by At

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

3

There are 3 best solutions below

11
On BEST ANSWER

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 convert function. 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} $$

3
On

Looks like the difference between the 0th term and the 1st term is 3. The difference between the 1st term and the 2nd term is $2$. So the difference between consecutive terms alternates between $2$ and $3$. One way to represent this is with the ceiling function:

$f(x) = 1 + \lceil2.5x\rceil$

4
On

hint

For each $n$ ,

$$u_{2n+1}=u_{2n}+3$$

$$u_{2n+2}=u_{2n+1}+2$$

Let $V_n=u_{2n}$.

then $$V_{n+1}=V_n+5$$ with $V_0=1$. thus $$V_n=V_0+5n=1+5n=u_{2n}$$

By the same, you get $$u_{2n+1}=5n+4$$