Simple formula for a sieries like 1, 2, 5, 10, 20, 50, 100, ...

8.4k Views Asked by At

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)

1

There are 1 best solutions below

3
On

Here's what I got:

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