Problem: Solve X mod Y for all positive integers. Do so without using multiplication or division.
To solve X mod Y without using multiplication or division, we will use the concept of remainders. The remainder when dividing X by Y is the amount left over after dividing X by Y as many times as possible.
Here's how we can solve X mod Y without multiplication or division:
1. Initialize a variable 'remainder' with the value of X.
2. While the remainder is greater than or equal to Y, subtract Y from the remainder.
3. Repeat step 2 until the remainder is less than Y.
4. The final value of the remainder is the solution to X mod Y.
Let's illustrate this with an example:
Suppose we want to solve 17 mod 5.
1. Initialize 'remainder' with 17.
2. Subtract 5 from the remainder: remainder - Y = 17 - 5 = 12.
3. Subtract 5 from the remainder again: remainder - Y = 12 - 5 = 7.
4. Subtract 5 from the remainder once more: remainder - Y = 7 - 5 = 2.
5. Since 2 is less than 5, we stop.
6. The final value of the remainder is 2.
7. Therefore, 17 mod 5 = 2.
Using this method, you can solve X mod Y for any positive integers without using multiplication or division.