Ludatha
06-23-2010, 03:07 PM
I have a function which returns the experiece required to get to a certain level. I need to write a function which returns the level you are currently on when you supply the experience.
I don't want to have a database with all the levels in there and then get PHP to check that, I just want a function.
Here is the function that returns the experience.
function experience($L)
{
// This function returns the experience required to get to a level $L
$a=0;
for($x=1; $x<$L; $x++) {
$a += floor($x+300*pow(2, ($x/7)));
}
return floor($a/33);
}
Here are the first 20 levels:
Level 1: 0
Level 2: 10
Level 3: 21
Level 4: 33
Level 5: 47
Level 6: 62
Level 7: 78
Level 8: 97
Level 9: 117
Level 10: 139
Level 11: 164
Level 12: 192
Level 13: 222
Level 14: 255
Level 15: 292
Level 16: 332
Level 17: 377
Level 18: 427
Level 19: 481
Level 20: 541
Do you think someone could help me write the function?
Thanks in advance!
I don't want to have a database with all the levels in there and then get PHP to check that, I just want a function.
Here is the function that returns the experience.
function experience($L)
{
// This function returns the experience required to get to a level $L
$a=0;
for($x=1; $x<$L; $x++) {
$a += floor($x+300*pow(2, ($x/7)));
}
return floor($a/33);
}
Here are the first 20 levels:
Level 1: 0
Level 2: 10
Level 3: 21
Level 4: 33
Level 5: 47
Level 6: 62
Level 7: 78
Level 8: 97
Level 9: 117
Level 10: 139
Level 11: 164
Level 12: 192
Level 13: 222
Level 14: 255
Level 15: 292
Level 16: 332
Level 17: 377
Level 18: 427
Level 19: 481
Level 20: 541
Do you think someone could help me write the function?
Thanks in advance!