It is all in the PDF
Basically I had this problem in my head when I was in ANU, and now I finally have the chance to write down the problem in its most basic form.
I just thought it is a good R practice session.
Fun times! I was also watching a Paul Erdos documentary at the time. What an extraordinary human being he was!