I'm not sure if I am explaining this right but basically I am trying to figure out a "near LCM".
If I have $9$ pears, $3$ apples and $4$ bananas the LCM is $36$. But there is a "near LCM" in $9$, where $3\cdot3=9$, $9\cdot1=9$ and $4\cdot2=8$, leaving a remainder of $1$. I am trying to determine that "near LCM" as well as the remaining amount. I know how to find the LCM, but I'm not sure how to calculate a "near LCM" where I could capture the remainder amount. I would want this amount to be the smallest remainder closest to the LCM.
My brain is having trouble thinking how to do this and I will be applying this as a php function to do the calculations. Thanks for any and all help.
Another member explained it as:
Find a positive number $N$ which is least that satisfies $N\equiv0,1,2\pmod{a_i}$ where $a_i$ are your given numbers.