# Modulus Problem

#### Idea

$$\displaystyle 1\leq k\leq m$$ so $$\displaystyle k$$ can be greater than $$\displaystyle 1$$

you used $$\displaystyle y$$ in the calculation $$\displaystyle z-y=-2$$

Here is another example

$$\displaystyle x=7;y=5;z=4;$$

$$\displaystyle k=1$$ , $$\displaystyle a=1,2,3$$ and $$\displaystyle b=3,2,1$$

$$\displaystyle k=2$$ , $$\displaystyle a=3,4,5,6,7$$ and $$\displaystyle b=5,4,3,2,1$$

$$\displaystyle k=3$$ , $$\displaystyle a=7$$ and $$\displaystyle b=5$$

for a total of $$\displaystyle 9$$ pairs

#### joshuaa

now i got the idea. i also tried to reverse x with y, i got same result.

thanks a lot.

you have said this method will work only if m is small. how small it should be? maximum number of m?

#### Idea

the formula should work for all $m$.
Here is another one that gives the number of solutions

$$\displaystyle \sum _k (k z-1)+\sum _k \min (x,y)+\sum _k (x-k z+y+1)$$

where $\min$ is the minimum function

The first sum is over all $k$ for which

$$\displaystyle 1\leq k<\min \left(\frac{x+1}{z},\frac{y+1}{z}\right)$$

in the second sum,

$$\displaystyle \frac{\min (x,y)+1}{z}\leq k \leq \frac{\max (x,y)+1}{z}$$

and in the third

$$\displaystyle \max \left(\frac{x+1}{z},\frac{y+1}{z}\right)<k\leq \left\lfloor \frac{x+y}{z}\right\rfloor$$

#### joshuaa

that is another creative formula. i understand how to implement it but i have 4 concerns

1)
in the first sum, if minimum function returns decimal, do i floor or ceil it?

2)
in the second sum, if k was between two decimals, do i floor or ceil them?

3)
in the 3rd sum, if maximum function returns decimal, do i floor or ceil it?

4)
in the second sum, let us assume x = 5, y = 10, and z = 2

then 3 <= k <= 5.5

let us assume we will floor 5.5

then 3<= k <= 5

now how to do the sum?

sum min(5,10) = 5
sum = 5 + 5 + 5?

#### Idea

1)floor
2)ceiling and floor
3)ceiling

$$\displaystyle \sum _{k=1}^2 (k z-1)+\sum _{k=3}^5 \min(x,y)+\sum _{k=6}^7 (x-k z+y+1)=$$

$$\displaystyle 4+15+6=25$$

since $\min(x,y)$ does not depend on $k$, yes it should be $5+5+5$

#### joshuaa

yeah that’s very Clear. thanks a lot.

Wanna tell you something!
i have completed higher mathematics courses such as Calculus III and Applied probability, and I have a solid foundation on them, but i still don’t have enough skills to think and create formula Like what you have done. do you suggest a book or course that will help me to think and be able to create some formulas to solve a specific problems such as the one I have posted here?

Similar threads