Question:
Design a Turing machine which takes two integers $x$ and $y$ and outputs $x^y$.
Note 1: The representation of $x$ and $y$ is not mentioned in the question but you can use either the binary or the unary one.
Note 2: I know how to design a Turing machine for $x\cdot y$ and I think it can be helpful in designing the machine which the question wants. But I don't know how. Any idea?
Thanks in advance.
Best Answer
You say you know how to design a Turing machine for $x\cdot y$.
Do you know how to check if a number is $0$, and go to a halting state?
Can you subtract $1$ from a number?
Start off the input with
x#y
, where#
is some separator symbol. Append $1$, givingx#y#1
. Now encode the following: