There are actually multiple formulas, as there are different types of experience groups: Erratic, Fast, Medium Fast, Medium Slow, Slow, and Fluctuating. All the formulas assume n=# of experience points. Hopefully you guys know what piecewise functions are!
This is for pokemon like Zangoose, Rampardos, Huntail, and Milotic.
Pokemon like Clefairy and Chansey fall here.
This is the most common group, with pokemon like Ferrothorn here.
Pokemon like Shaymin and Mew are here.
Pokemon like Houndoom or Rayquaza go here.
If you want to see what numbers correspond to what level, go here.
Note that the stat formulas to gain experience vary between Gen I-IV and Gen V.