A father had a sum of beans, say less than 30,000, which he left to his two sons. To divide the beans, the first son suggested, "Let's quicken this dividing process; why don't we lay them out in piles of seven, and then we can each pick one pile at a time until they're all gone?" The second son agreed. So they laid them all out in piles of 7... but there were 3 left over! As that plan didn't work out, the second son suggested, "Okay, well maybe if we pile them by nines, then each take one pile at a time until there are no more." So the two sons grouped the beans into piles of 9... but there were 7 left over! This wasn't appearing to work no matter how hard they tried, so they decided to do it the long way... one at a time.

So the first son, being the elder, took his one bean first. Then the second son, worried that the first son might end up getting an extra odd one at the end, went ahead and took two beans. Then the first son, upset that the second son took two beans, took three beans. And so each son in turn took one more than the other, until they could no longer continue the pattern... but there were 196 left over!

After this somewhat-expected familial drama, the two sons finally decided that they should plant the beans together, so that they and all their friends might harvest them for food. So their dilemma was ended. They planted the beans together, spacing them into equal rows the only possible way to form a multiple-row rectangle... and there were none left over. The beans sprouted, the two sons and all their friends never went hungry again, and everyone lived happily ever after. The end.

How many beans did the sons plant? Then what are the dimensions (in beans) of the rectangular field?