Please help find Hidden algorithm:
In: Out:
4 -> 36
21 -> 693
35 -> 1155
36 -> 2340
43 -> ????
Puzzling Stack Exchange is a question and answer site for those who create, solve, and study puzzles. It only takes a minute to sign up.
Sign up to join this communityPlease help find Hidden algorithm:
In: Out:
4 -> 36
21 -> 693
35 -> 1155
36 -> 2340
43 -> ????
SirGrapefruit has observed that
the output always seems to be a multiple of the input.
Note also that
the ratio is always a power of 2, plus 1.
If we write
$f(x) = (2^{g(x)}+1)x$ where perhaps $g$ always yields positive integers,
then we need
g(4) = 3, g(21) = g(35) = 5, g(36) = 6.
We may for instance take
$g(n)=\left\lfloor\frac{\left\lfloor\sqrt{8n+1}\right\rfloor-1}4\right\rfloor+2$ [EDITED to add:] where, as Kruga observes in a comment on another answer, the inner flooring is redundant so we could instead just write $g(n)=\left\lfloor\frac{\sqrt{8n+1}-1}4\right\rfloor+2$
which is
one more than the number of even-index triangular numbers (0, 3, 10, 21, 36, ...) up to $n$.
[EDITED to add:] Oops, I hadn't noticed that we were asked for f(43) as well as f. With the formula I gave above,
g(43)=g(36) since there are no triangular numbers at all between 36 exclusive and 43 inclusive, so f(43)=65×43=2795.
Partial Observation:
In all examples, the output is divisible by the input.
Therefore the problem may be able to be reduced to the following:
With $f(x) = x * g(x)$, find a Function $g$ that maps $g(4)=9$, $g(21)=33$, $g(35)=33$ and $g(36)=65$.
I don't know if my solution and solution of @Gareth McCaughan are similar, but just posting since I find my proof more intuitive.
In: Out:
4 -> 36
21 -> 693
35 -> 1155
36 -> 2340
43 -> ????
Now we observe following pattern (please refer to link as I'm unable to hide the table):
Let's discuss following properly:
Consider the following function which defines LHS and RHS of Table2 given in the hint above.
On an input n and it returns smallest number k = 2*m + 1 such that (2*m - 1)*(2*m + 1) upper-bounds the input, where m and n are natural numbers.
We observe that Table2 follows the above function.
Hence for n = 4,
It should be 5, since 4 <= 5*3 and 3*1 < 4.
For n = 21,
It should be 7, since 21 <= 7*5 and 5*3 < 21.
For n = 35,
It should be 7, since 35 <= 7*5 and 5*3 < 35.
For n = 36,
It should be 9, since 36 <= 9*7 and 7*5 < 36.
For n = 43,
It should be 9, since 43 <= 9*7 and 7*5 < 43.
Now since,
Since sqrt(Out/In + 16) = 9
Therefore,
Out = 65 * In = 65 * 43 = 2795.
According to Gareth, $g(n)$ can be represented as
$(\left\lfloor(\left\lfloor\sqrt{8n + 1}\right\rfloor - 1)/4\right\rfloor) + 2$
If we use 43 as $n$, we get 6.
$2^6+1=65$
Hence,
$43*65=2795$, So the answer is $2,795$.