# Guessing the pattern: f(43)=13, f(79)=40,

I have these numbers and I couldn't guess the pattern of this question it might be easy or it might be hard whatever these are the numbers $$f(43) = 13\\ f(79) = 40\\ f(111) = 120\\f(138)=161\\f(169) = 247\\f(256) = ???$$ I tried to sum digits of the number but get nothing can any one help /:

• Can you tell us a bit about where this puzzle comes from? Nov 28 '17 at 16:42
• There are an infinite number of functions that will agree at the 5 points given but have different values at 256. Nov 28 '17 at 21:44
• @chepner This objection applies to any "what's next in this sequence" question. Please move along. Nov 29 '17 at 9:26

619

Reason: f(x*10 + y) = … where x: N, y: [0, 9]

Because: $f(x*10+y) = x^2 - y$ $$f(43) = 4^2 -3 = 13$$ $$f(79) = 7^2 - 9 = 40$$ $$f(111) = 11^2 - 1 = 120$$ $$f(138) = 13^2 - 8 = 161$$ So: $$f(256) = 25^2 - 6 = 619$$

• Why not explain notation like f(x*10 + y) = … where x: N, y: [0, 9]? Nov 29 '17 at 15:49
• @user28434 As you wish Nov 29 '17 at 16:00

Since I am new to this notation style, I found the notation confusing because:

Using $f(xy)$ notation, $f(111)$ is ambiguous to me, as $x$ could be $1$, and $y$ could be $11$, such that $f(111)$ could also become $1^2 - 11$ resulting in $-10$. But, even before that, I thought $xy$ meant $x \times y$.

So, I just wanted to reformat it in the imperative style I am used to:

$$f(xy) = x^2 - y$$ becomes: $$f(z) = \lfloor z/10 \rfloor^2 - (z\bmod10)\,,$$ which becomes, in pseudocode: $$f(z) = \mathrm{power}( \mathrm{floor}(z/10) , 2) - ( \mathrm{modulus}(z,10) )$$

So, in JavaScript (which is easy to test in web browsers) it would be:

function f(z) { return Math.pow( Math.floor(z/10), 2) - z%10; }

• It could also be shown as f(x \Vert y), which produces $f(x \Vert y)$, as long as you clarify the meaning. $\Vert$ is a symbol commonly used for digit concatenation, per Wolfram Mathworld and Math.SE. (I do like showing the explicit formula for a single number $z$, but I think this conveys @rudra's intention better.) Nov 28 '17 at 22:11