I'm making a level calculation system, based on geometric progression, with initial term $a_1=100$ and ratio $r=2$.
So, we have an equation for min. $x$ and max. $a$ XP values per level $n$:
$a_n = a_1*r^{n-1} \\ x_n = a_{n-1} = a_1*r^{n-2}$
I need to get a level (aka. $a$ term) basing on current player's XP (aka. $p$ point), like in next four examples:
$p = 64 = a_1 \\ p = 128 = a_2 \\ p = 256 = a_3 \\ p = 512 = a_4$
What formula will suit me in this case?
$a_n=100 \cdot 2^{n-1}$ seems to be what you want
Added: if you are given a value $x$ and want to find the closest $a_n$ by ratio, you can just compute $\log_2 \frac x{100}$ and round to the nearest whole number, then add $1$. For example if you are given $142$ you do $\log_2 \frac {142}{100}\approx 0.5059$, which rounds to $1$. Adding $1$ gets $2$, so the closest value is $a_2$. The addition of $1$ comes from the fact that we counted from $1$.