开发者

How to create a Turing machine that takes a single digit decimal number from 0 - 9 and output the cube

I'm working on a project for a Turning machine but having problems conceptualizing the steps.

f(x) = x^3, where x is a single digit between 0 - 9 inclusive.

Based on my understanding I am to convert the number to binary but how do I find the cube of a number in binary.

Also, how do I write the cube on the tape.

So far I'm thinking I should create a state diagram that accepts the 开发者_JAVA百科binary versions of 0-9 but what next?


I would do it like this:

  • Write a copy of the number to the left of your current number
  • Write another copy to the left of that
  • Multiply the original number with the first copy, erasing the copy
  • Multiply the result by the second copy, erasing that

You will need to write a copy and a multiply "subroutine" (using states) and jump into those by setting the right states. But I think this should be doable (if a lot of work). But probably less work than encoding all cubes from 0 to 9.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜