- #1
Goldenwind
- 146
- 0
Solving equations with "mod"
I have a homework problem. I'm in computer science, however one of my programs requires me to solve this equation. I'm afraid it's beyond my expertise.
(a * x) mod b = 1
This needs to be rearranged in the form of x = ...
Due to the existence of "mod", I get confused.
Please don't solve it for me. I'm just looking for a little nudge to help me get over this hump.
See above.
My main goal solving this was to try and get rid of that "mod". Thinking about it logically, if x mod y = 0, that means that x / y = Z, where Z is some integer. I also believe it means there exist values of x and y such that all integer values of Z would exist.
Base equation
(a * x) mod b = 1
Subtracting 1 from both sides
((a * x) - 1) mod b = 0
Converting to division
((a * x) - 1) / b = Z
Solve like normal
x = (Z*b + 1) / a
Now the problem is, the Z is throwing me off. Do I just choose a value? It would make sense for remainders that there are multiple values of x that keep the equation in balance. Due to this being programming, x can be my only unknown. Am I on the right track?
Homework Statement
I have a homework problem. I'm in computer science, however one of my programs requires me to solve this equation. I'm afraid it's beyond my expertise.
(a * x) mod b = 1
This needs to be rearranged in the form of x = ...
Due to the existence of "mod", I get confused.
Please don't solve it for me. I'm just looking for a little nudge to help me get over this hump.
Homework Equations
See above.
The Attempt at a Solution
My main goal solving this was to try and get rid of that "mod". Thinking about it logically, if x mod y = 0, that means that x / y = Z, where Z is some integer. I also believe it means there exist values of x and y such that all integer values of Z would exist.
Base equation
(a * x) mod b = 1
Subtracting 1 from both sides
((a * x) - 1) mod b = 0
Converting to division
((a * x) - 1) / b = Z
Solve like normal
x = (Z*b + 1) / a
Now the problem is, the Z is throwing me off. Do I just choose a value? It would make sense for remainders that there are multiple values of x that keep the equation in balance. Due to this being programming, x can be my only unknown. Am I on the right track?