Here is the formula in equation form where L is the level you're calculating for (thanks Lord Elric):
The original program has been written in Python by Slowbyte. JavaScript version written by Sir T Bone. It should be easy to change this program to output the levels differently for use in other programming languages, etc. The formula is not guaranteed to be accurate. You can view the source code in JavaScript, Python, MS Excel, PHP. and Visual Basic.
You need to be able to run JavaScript to see the output of this program. The formula doesn't mean much above level 100, because level 99 is the highest level allowed in RuneScape.
The following code is used above to generate the experience table:
<SCRIPT LANGUAGE="JavaScript"> <!-- document.close(); document.open(); document.writeln('Begin JavaScript output:'); document.writeln('<PRE>'); points = 0; output = 0; minlevel = 2; // first level to display maxlevel = 200; // last level to display for (lvl = 1; lvl <= maxlevel; lvl++) { points += Math.floor(lvl + 300 * Math.pow(2, lvl / 7.)); if (lvl >= minlevel) document.writeln('Level ' + (lvl) + ' - ' + output + ' xp'); output = Math.floor(points / 4); } document.writeln('</PRE>'); document.close(); // --> </SCRIPT>
This is the very original code by Slowbyte:
points = 0 for level in range(1,100): diff = int(level + 300 * math.pow(2, float(level)/7) ) points += diff str = "Level %d = %d" % (level + 1, points / 4) print str
MS Excel version by Mugol:
Cell A1: 1 Cell B1 formula: =ROUND.DOWN(A1+300*POWER(2;A1/7);0)/4 Cell A2: 2 Cell B2 formula: =B1+ROUND.DOWN(A2+300*POWER(2;A2/7);0)/4 Fill the rest of the first column with numbers 3, 4, ... Copy B2 field formula down.
PHP version by Gazza (aka Jargon on RS)
<?php function experience($L) { $a=0; for($x=1; $x<$L; $x++) { $a += floor($x+300*pow(2, ($x/7))); } return floor($a/4); } for($L=1;$L<100;$L++) { echo 'Level '.$L.': '.experience($L).'<br />'; } ?>
Public Function experience(ByVal lvl As Integer) Dim a As Long Dim x As Integer For x = 1 To lvl a = a + Int(x + 300 * (2 ^ (x / 7))) Next x experience = roundDown(a / 4) End Function
Source: RSDemon Online, RSDemon Community