This is actually a very difficult problem. As far as i am aware it was solved by the prolific mathematician Leonard Euler. It relates to pentagonal numbers(don't know why). I have the code for your problem if you want it, but i will not post it now in case you want to get this thing by yourself. I will pm it if you ask.
Ancient Dragon commented: you are right :) +34
ccube921 commented: awesomeness +3
frogboy77 73 Posting Pro in Training