Mohan is selling cookies at the economics fair. As he decides how to package the cookies, he finds that when he bags them in groups of 4, he has 3 left over. When he bags them in groups of 5, he has 2 left over. When he bags them in groups of 7, he has 4 left over. What is the least number of cookies that Mohan could have?
Thanks for the last one @CalTheGreat!
We need to find the LCM of 17, 6, and 2 and add one to it.
The LCM of 17, 6, and 2 is 102 (prime factorization)
Therefore, our k=103
Hope this helped!
i=0;j=0;m=0;t=0;a=(4, 5, 7);r= (3, 2, 4);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
/* CHINESE REMAINDER THEOREM + MODULAR MULTIPLICATIVE INVERSE */
OUTPUT = 140 m + 67, where m =0, 1, 2, 3.......etc.
The minimum number of cookies =67