In a RPG context, what are the ways to quickly find a character's level, given his XP? There are two cases which I am looking at:
- For when a formula is defined, like in the case of D&D, which is N = N*(N-1)*500, where N is the desired level.
- When no formula is defined, each level has an amount of XP require which is defined by a table.
I guess the easiest way is to do a for loop and subtracting the XP required for that level from the character's XP pool, till he reaches a point where you can't attain the next level. What other ways are there to, given a character's XP, to find his level?
Edit: The language is PHP