# Turing Machines as Functions

Learn about the various applications of Turing machines.

Turing machines can also act as functions by leaving output on the tape. The following $\text{TM}$ computes $n \;\text{mod}\; 2$. We encode numbers in *unary* notation, so $1 = 1, 2 = 11, 3 = 111$, etc. The idea is to use two states for evenness vs. oddness and then leave either a $0$ or $1$ on the tape.

Get hands-on with 1200+ tech skills courses.