Unary coding (source code)

= Unary coding
{wiki=Unary_coding}

Unary coding is a simple form of encoding used in data compression and representation, especially in the context of variable-length codes. It is particularly useful for encoding natural numbers in a way that allows for efficient decoding. In unary coding, a non-negative integer \\( n \\) is represented by a sequence of \\( n \\) ones followed by a single zero. For example: - The number \\( 0 \\) is encoded as \`0\`.