that's my choice of approach as well - i didn't run the program though. because the fun part is done and what left is just the time-consuming part...
the fun part is completed with two correct answers by Gao Shous. for most people who is new to this kind of problem, it is already fun enough to check these answers. :)