A trader was moving along the road with a basket full of eggs on top of his head. An idler walking on the road dashes the trader thereby breaking the eggs. He is asked by the trader to pay for his loss. Unfortunately, the trader does not know the number of eggs he had in his basket. But remembers the following ,
If counted in pairs, 1 remain
If counted in threes, 2 remain
If counted in fours, 3 remain
If counted in fives, 4 remain
If counted in sixes,5 remain
If counted in sevens, none remain
His basket cannot accomodate more than 150 eggs
What is number of eggs in the traders basket?
so say t is total eggs
t<=150
t is odd
2 more than multiple of 3, or 1 less than multiple of 3
3 more than multiple of 4, or 1 less than of 4
4 more than of 5, or 1 less
5 more than of 6, or 1 less
Multiple of 7
multiples of 7 to 150
7,14,21,28,35,42,49,56,63,70,77,84,91,98,105,112,119,126,133,140,147
Two more than multiples of 3
21-2 = 19, no
35-2=33, huh.
49-2 = 47, no
63-2=61, no
77-2 = 75, huh.
91-2 = 89, no
105-2=103, no
119-2 = 117, huh.
Rest are no's.
35, 77, 119
35-3= 32, huh.
77-3 = 75, huh.
119-3 = 116, huh.
35-4 = 31, no.
77 - 4 = 73, no
119-4 = 115, yes.
119.
Just to check, 119-5 = 114,/6 = 19, yes, and it's a multiple of 7,
Apologies for my prior mistake and thanks for bringing this to my attention, please check to ensure correctness.
This isn’t the correct answer Hugo! You didn’t compare your result to the criteria that defines the problem.
If you did compare you would see this:
If 75 eggs are counted in threes, then 0 remain; it should have 2
If 75 eggs are counted in fives, then 0 remain; it should have 4
If 75 eggs are counted in sixes, then 3 remain; it should have 5
And the most obvious one:
If 75 eggs are counted in sevens, then 5 remain; it should have 0
Here’s a hint: Reread the question, and notice that the remainders are all one less than the divisor, except for seven.
It’s not likely you will know what to do with this hint. So here are few more hints.
What do you get by taking the LCM of the divisors that have a remainder other than zero?
What happens when 1 is subtracted from this LCM?
Is the result divisible by 7?
If not, then what about 2*(LCM - 1)?
.N mod 2 = 1
N mod 3 = 2
N mod 4 = 3
N mod 5 =4
N mod 6 =5
N mod 7 =0
Using Chinese Remainder Theorem plus Modular Multiplicative Inverse which are incorporated in this short computer code, we get the following:
i=0;j=0;m=0;t=0;a=(2, 3, 4, 5, 6, 7);r= (1, 2, 3, 4, 5, 0);c=lcm(a); d=c / a[i];n=d % a[i] ;loop1:m++; if(n*m % a[i] ==1, goto loop, goto loop1);loop:s=(c/a[i]*r[j]*m);i++;j++;t=t+s;m=0;if(i< count a, goto4,m=m);printc,"m + ",t % c;return
OUTPUT =420n + 119, where n =0, 1, 2, 3........etc.
Therefore, the smallest number of eggs he had was = 119 eggs.