148k views
5 votes
Consider rem( a, d ) defined as follows (for positive integers):

a.rem(a,d) = a if a < d otherwise
b.rem(a,d) = rem(a-d, d)
According to this definition, what is rem(17,4)?

1 Answer

5 votes

Final answer:

According to the given recursive definition, rem(17, 4) is equal to 1.

Step-by-step explanation:

According to the given definition, rem(a, d) is defined as:

  1. If a is less than d, then rem(a, d) is equal to a.
  2. If a is greater than or equal to d, then rem(a, d) is equal to rem(a - d, d).

To find rem(17, 4), we can apply this definition:

  1. 17 is greater than 4, so we apply the second part of the definition.
  2. Subtracting 4 from 17, we get 13.
  3. Since 13 is still greater than or equal to 4, we apply the definition again.
  4. Subtracting 4 from 13, we get 9.
  5. Next, we apply the definition again with 9 and 4, subtracting 4 from 9 to get 5.
  6. Finally, we apply the definition a final time with 5 and 4, subtracting 4 from 5 to get 1.

Therefore, rem(17, 4) is equal to 1.

User DaGGeRRz
by
8.5k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.