Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8437969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:34:47+00:00 2026-06-10T07:34:47+00:00

If I know the value of $c_xp , how can I find $c_level without

  • 0

If I know the value of $c_xp, how can I find $c_level without writing 100’s of if statements.

Level     XP
1         0-99
2         100
3         500  +400 xp points from last level
4         1000 +500 xp points from last level
5         1600 +600 xp points from last level
6         2300 +700 xp points from last level
7         3100 +800 xp points from last level
8         4000 +900 xp points from last level

And so on.

$c_level = ;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:34:48+00:00Added an answer on June 10, 2026 at 7:34 am

    If I understand your pattern correctly:

    $c_level = floor((-1 + sqrt(1 + 4 * ($c_xp + 500) / 100 * 2)) / 2) - 1;
    

    You are adding 100, then 400, then 500, 600, 700, 800, and so on. Because 100 kind of breaks the pattern, we are going to ignore it for now.

    Assuming you were going after the pattern

    Level     XP
    
    1         0-99
    2         100-299
    3         300-599
    4         600-999
    5         1000-1499
    6         1500-2099
    

    This would be easier, because the increments are 100, 200, 300, and so on. Anything under 100 would be level 1. Anything under 300 would be level 2. Anything under 600 would be level 3. Conveniently:

    0+1=1 (hence 100)
    0+1+2=3 (hence 300)
    0+1+2+3=6 (hence 600)
    

    and so on and so fourth. The sum of the first x integers is 0.5 * x * (1 + x) = y, where y is the sum – see http://en.wikipedia.org/wiki/Summation.

    In our case, we have 100 times the sum. We can simply divide our XP by 100 to get y, and use the quadratic formula to solve for x. In the case if XP is 600, the level is 4.

    600 / 100 = 6, and 0.5 * x * (1 + x) = 6. The quadratic formula tells us x is 3. We have to use floor() on it and add 1 for reasons I cannot explain. Long story short to adjust with the lack of patter under 500 points, we add 500 and subject 2 to the final amount for the formula to work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know C# has both value and reference types, but how can you do
I know you can not set a key value dynamically, but what about the
Can anyone tell me how can I convert a value which I know to
For any given type i want to know its default value. In C#, there
The file looks like: a1,b1 a2,b2 ... I know the value a2. How to
How do you know if a value was passed in on a property that
I have a Grid and I know the X-value and Y-Value of where I
I know that when passing an object by value to a function, the move
I know how to change the value of attributes with SlowCheetah, but how would
Anyone know why this is not returning a value? Example $item2['data'] where it =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.