Partitions and Dynamic Programming

There are exactly 7 ways to write the number 5 as a sum of other positive numbers:
  1. 5 = 5
  2. 1+4 = 5
  3. 1+1+3 = 5
  4. 1+1+1+2 = 5
  5. 1+1+1+1+1 = 5
  6. 2+3 = 5
  7. 2+2+1 = 5
There is a convention to say that P(5) = 7, meaning that there are 7 partitions of the number 5. Such a notion goes back to the times of Euler, in the 1700’s. At that time, in 1735, an amateur mathematician managed to find the first N for which P(N) had over 100 digits. As far as I know there were no laptops around during those days, hence it is truly marvelous what that young man accomplished. Unfortunately his name and story was lost in time, and we only know about this tale thanks to one side note from Euler himself in one of his books. Of course, today with the advanced of powerful computers, it is possible to find way bigger numbers. For instance, using an average laptop, it is possible to find the first number N for which P(N) has 200 or more digits:
 
P(N) = 10058155246188730579133793592616739522467948239017058084404186577341384610971742975338028721654506806317878278595464025098826576996337367647022780696970792316202135374548231989069758437576412531956049

P(N) above is the first one to break into the 200-digits long category.
What’s the value of N? Solution in the next post…
 

Comments

Popular posts from this blog

Changing the root of a binary tree

ProjectEuler Problem 719 (some hints, but no spoilers)

The Power Sum, a recursive problem by HackerRank