Suppose we want to encode the natural numbers as bit strings as follows:
0 = λ // the empty string
1 = 0
2 = 1
3 = 00
4 = 01
5 = 10
6 = 11
7 = 000
8 = 001
9 = 010
10 = 011
11 = 100
12 = 101
13 = 110
14 = 111
15 = 0000
...
How can we calculate the encoding of any given number? For example, how do I calculate the encoding of 173?
My professor stated that this method works:
Given a number x, add a “1” to the beginning of x, calculate the number that 1x encodes in binary, then subtract 1 from the answer.
However, I have failed to get this to work.
Any help is much appreciated.
Clarified this with my professor today. The method is simple: