I know this is basic calc but I am a bit rusty and I want to be sure I am doing it right.
I am implementing a user level system on my site and I need to display each user's level on their profile. They already have some points and from this I want to calculate what level they are on.
I want to increase the level by a factor of 3 where the first level is just 1 point.
So, I would proceed as follows:
level = 0;
factor = 3;
points = 243; //as an example, this would be level 6.
while (points >= 1) {
points = points/factor;
level++;
}
What would you recommend me do? Is this the best way? Is there a more effective way? I am looking for performance and scalability.