Z
Z
ZIK13372020-04-28 09:16:11
Algorithms
ZIK1337, 2020-04-28 09:16:11

Turing machine for finding the remainder of a division?

Under the "single" number system is meant the recording of a non-negative
integer with the help of sticks - as many sticks should be written out,
what is the value of the number; for example: 2 →∣ ∣, 5 →∣ ∣ ∣ ∣ ∣ ∣ , 0 → <empty word>.

R07JhdC.jpg
pBGJicu.jpg

Div did it, but there, when subtracting, the process does not stop when the remainder becomes less than the divisor. You just need to stop right there, the rest in response is needed, how can this be done?
Check every time which number is greater, I think it will be too confusing

for div to be implemented something like this: the
divisor is copied to the left of the dividend (to the left of the "-"), and then in the loop one first stick is erased from the copy of the divisor and from the dividend, as the copy of the divisor is over - one stick is added to the end of the word (after "=")
after that, the divisor is copied again (to the left of the "-") and subtracted again until the dividend runs out

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
ZIK1337, 2020-04-28
@ZIK1337

Nobody knows how to stop if the remainder is less than the divisor?
Example:
Given: |||/||
||-|||/||=
|-||/||=
-|/||=|
||-|/||=| - this is how div works for me, after "=" - an integer part when dividing
, and at this step you need to stop and fix 1 in response (the number between - and /),
but according to the algorithm for div, I will first remove another stick, and then already finished when he sees that there is nothing to the left of /:
|-/||=|
-/||=|
|

X
xmoonlight, 2020-04-28
@xmoonlight

Div did it, but there, when subtracting, the process does not stop when the remainder becomes less than the divisor.
First we check the result, then we apply it. You are the opposite!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question