3

I'm looking for a simple formula that will give a series that looks like this:

$1; 2; 5; 10; 20; 50; 100; ...$
That means a function that will give this output:
$f(1) = 1$
$f(2) = 2$
$f(3) = 5$
$f(4) = 10$
$f(5) = 20$
$f(6) = 50$
$f(7) = 100$

The inverse function also would be nice!
$f^{-1}(5) = 3$
$f^{-1}(20) = 5$
$6 \leq f^{-1}(75) \leq 7$

To express it abstractly:

$$f(n) \leq x \leq f(n+1)\implies n \leq f^{-1}(x) \leq n+1$$

Does anyone have an idea, especially for the inverse function?


With the help of Integrator f is

$$f(n) = \left(\left(n \mod 3\right)^2 + 1\right)\cdot10^{\lfloor\frac{n}{3}\rfloor}$$

(Starting with $0$ instead of $1$ but that's no issue for me)

daOnlyBG
  • 2,711
  • Related: http://math.stackexchange.com/questions/93648/what-do-you-call-numbers-such-as-100-200-500-1000-10000-50000-as-opposed-to – Henry Nov 07 '14 at 16:39
  • 1
    Actually, I think I have a solution. I'm posting it up as soon as I verify it. – daOnlyBG Nov 07 '14 at 16:41
  • 1
    Your solution is the same as Justin L. Brown's at OEIS A051109. In fact you are starting at $f(0)=1, f(1)=2,\ldots$ – Henry Nov 07 '14 at 16:44
  • @Henry Thank you. Integrator has found it first but thank you anyways. I quite honestly didn't know about OEIS before. – BrainStone Nov 07 '14 at 16:46

1 Answers1

4

Here's what I got:

$$f(x) = \left(((x-1)\mod3)^2+1\right)\cdot10^{ \lfloor{\frac{x-1}{3}}\rfloor}$$

daOnlyBG
  • 2,711
  • I already put this formula in my post. Also where is your $z$ comming from? I think that should be a $(x - 1)$. – BrainStone Nov 07 '14 at 16:53
  • Ah yes, you beat me to it- though I believe I mapped mine along f(1)=1, f(2)=5, etc. whereas yours is f(0)=1, f(1)=2, etc. I don't know which "z" you are referring to. – daOnlyBG Nov 07 '14 at 16:56
  • It is no issue using a different starting value. The $z$ is a $x$. The $x$ in $10^{\lfloor\frac{x}{3}\rfloor}$. It should be $10^{\lfloor\frac{x - 1}{3}\rfloor}$ – BrainStone Nov 07 '14 at 17:05