How could I evaluate this in code?

Posted by WM on Stack Overflow See other posts from Stack Overflow or by WM
Published on 2010-05-02T13:13:26Z Indexed on 2010/05/02 13:27 UTC
Read the original article Hit count: 249

Filed under:
|

There is a medieval puzzle about an old woman and a basket of eggs. On her way to market, a horseman knocks down the old woman and all the eggs are broken. The horseman will pay for the eggs, but the woman does not remember the exact number she had, only that when she took the eggs in pair, there was one left over; similarly, there was one left over when she took them three or five at a time. When she took them seven at a time, however, none were left. Write an application that can determine the smallest number of eggs the woman could have had.

It might be a multiple of seven because there are no eggs left when it's seven at a time. But I have a problem.

49 eggs -1=2*24
49 eggs -1=3*16
49 eggs-4=5*9
49 eggs-0=7*7

© Stack Overflow or respective owner

Related posts about java

Related posts about homework