How to Solve for Y in the Equation X = Y%Z?

  • Thread starter Superposed_Cat
  • Start date
In summary, the conversation discusses how to solve for y in the equation x=y%z, with various examples and patterns being shown. The formula y=z*i+x is suggested, with the condition that i is an integer greater than 0. However, it is noted that the formula y=nz+x, where x, y, z, and n are all integers, is a more inclusive solution.
  • #1
Superposed_Cat
388
5
Hey all, if x=y%z How do i solve for y?
 
Mathematics news on Phys.org
  • #2
Superposed_Cat said:
Hey all, if x=y%z How do i solve for y?
Take an example:

[tex]3=12\%9[/tex]

So in this case we have that x=3, z=9, and y=12. But also,

[tex]3=3\%9[/tex]
[tex]3=21\%9[/tex]
[tex]3=-6\%9[/tex]
[tex]3=(100*9+3)\%9[/tex]

Are you seeing the pattern? Can you develop a simple formula that gives us every possible y value that satisfies this equation?
 
  • #3
y=z*i+x, i is int > 0
 
  • #4
Why greater than 0? -6= 3%9 because -6= 3+ (-1)9.

(I would say "-6= 3 (mod 9). "%" is computer code.)
 
  • #5
HallsofIvy said:
Why greater than 0? -6= 3%9 because -6= 3+ (-1)9.
Yes, ## y = nz+x## ##∀x,y,z,n ∈ ℤ ## is more inclusive.
 

FAQ: How to Solve for Y in the Equation X = Y%Z?

1. What does "X=y%z" mean?

In this equation, X is equal to the remainder when y is divided by z. This is also known as the modulus or modulo.

2. How do I solve for y?

To solve for y, you need to isolate it on one side of the equation. First, divide both sides of the equation by z. This will give you X/z = y%z. Then, use the definition of modulus to rewrite y%z as y-z*floor(y/z), where floor(y/z) is the greatest integer less than or equal to y/z. Finally, add z*floor(y/z) to both sides to get y = X+z*floor(y/z).

3. Can this equation have multiple solutions for y?

Yes, this equation can have multiple solutions for y. For example, if X=4 and z=2, then y can be equal to 2, 4, 6, 8, etc. As long as y is a multiple of z, the equation will hold true.

4. Can this equation be solved for other variables besides y?

Yes, this equation can be solved for any of the variables. For example, if you want to solve for z, you can rearrange the equation to be z = X/y. Similarly, if you want to solve for X, you can use the equation X = y%z.

5. Are there any restrictions or limitations to this equation?

There are a few restrictions to keep in mind when using this equation. First, y and z must be positive integers. Additionally, if z=0, the equation is undefined. Furthermore, this equation only works for integers and not for fractions or decimals. Lastly, there may be multiple solutions for y, as mentioned in question 3.

Similar threads

Replies
3
Views
1K
Replies
11
Views
1K
Replies
15
Views
2K
Replies
1
Views
1K
Replies
4
Views
501
Replies
1
Views
1K
Back
Top