Function Repository Resource:

BinaryCodedTernary

Source Notebook

A self-delimiting number representation

Contributed by: Stephen Wolfram

ResourceFunction["BinaryCodedTernary"][n]

gives the digits for the integer n encoded in binary-coded ternary.

Details

In the binary-coded ternary system, one takes the ternary (base-3) representation, and converts each digit to a pair of binary (base-2) digits, while handling the beginning and end of the sequence in a special way.

Examples

Basic Examples (2) 

Binary-coded ternary for 9:

In[1]:=
ResourceFunction["BinaryCodedTernary"][9]
Out[1]=

Binary-coded ternary for numbers up to 30:

In[2]:=
ArrayPlot[
 PadLeft[Table[ResourceFunction["BinaryCodedTernary"][n], {n, 30}]], Mesh -> True]
Out[2]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.1 – 13 September 2021
  • 1.0.0 – 14 January 2019

License Information