TOPICS
Search

Ternary


Ternary is the base-3 numeral system in which only the digits 0, 1, and 2 are used. Ternary numbers arise in a number of problems in mathematics, including some problems of weighing. However, according to Knuth (1998), "no substantial application of balanced ternary notation has been made" (balanced ternary uses digits -1, 0, and 1 instead of 0, 1, and 2).

The ternary representations of the nonnegative integers, written as digit strings, are 0, 1, 2, 10, 11, 12, 20, ... (OEIS A007089). The positive integers whose ternary representations are primes when read as decimal integers begin 2, 4, 10, 22, 34, 46, ... (OEIS A036954). For example, 4 has representation (11)_3, and the decimal integer 11 is prime. This construction tests the decimal interpretation of the digits, rather than the original ternary value.

Ternary

The illustration above shows a graphical representation of the integers from 0 to 25 in ternary, and the following table gives the ternary equivalents of the first few decimal integers. The concatenation of the ternary digits of the consecutive numbers 0, 1, 2, 3, ... gives (0), (1), (2), (1, 0), (1, 1), (1, 2), (2, 0), ... (OEIS A054635).

111110221210
221211022211
3101311123212
4111411224220
5121512025221
6201612126222
72117122271000
82218200281001
910019201291002
1010120202301010

Ternary digits have the following multiplication table.

×012
0000
1012
20211

For a three-state totalistic cellular automaton with a neighborhood of three cells, a ternary representation uniquely identifies its rule. The three colors (white, gray, and black) correspond to the three numbers 0, 1, and 2 (Wolfram 2002, pp. 60-70 and 886). For example, the ternary digits 0211020_3 lead to the code 600 totalistic cellular automaton.

Every even number represented in ternary has an even number (possibly 0) of 1s. This is true since a nonnegative integer is congruent modulo b-1 to its digit sum in base b>=2. In the case b=3, there is only one digit (1) which is not a multiple of b-1, so all we have to do is "cast out twos" and count the number of 1s in the base-3 representation.

The following table gives 2^n for n=1, 2, ... in ternary.

2^1=2_3
(1)
2^2=11_3
(2)
2^3=22_3
(3)
2^4=121_3
(4)
2^5=1012_3
(5)
2^6=2101_3
(6)
2^7=11202_3.
(7)

N. J. A. Sloane conjectured that for any integer n>15, 2^n always has a 0 in its ternary expansion (Sloane 1973, p. 98; Vardi 1991, p. 28). Known positive integer values of n such that 2^n lacks a 0 begin with 1, 2, 3, 4, 15, ... (OEIS A102483), with no others up to 10^5 (E. W. Weisstein, Apr. 8, 2006). The positions (counting from 1 at the least significant ternary digit, with 0 denoting absence) of the first 0 digit in (2^1)_3, (2^2)_3, ..., are 0, 0, 0, 0, 3, 2, 2, 4, 4, 5, 4, 2, 2, 4, 0, 3, 4, ... (OEIS A117970).

It is conjectured that, for positive integers n, 2^n has a 1 in its ternary expansion except when n=1, 3, or 9. This is equivalent to the conjecture about the occurrence of a 2 in 2^(n-1) (Saye 2022). No further exceptions were found up to 10^5 (E. W. Weisstein, Apr. 8, 2006).

Erdős and Graham (1980) conjectured that no power of 2, 2^n, for integers n>8 is a sum of distinct powers of 3. This is equivalent to the requirement that the ternary expansion of 2^n always contains a 2 for n>8. For positive integers n, Vardi (1991) verified that the only values of n for which 2^n has no 2 in its ternary expansion are 2 and 8 up to n=2·3^(20) approx 6.97×10^9. The positions (counting from 1 at the least significant ternary digit, with 0 denoting absence) of the first 2 digit in (2^1)_3, (2^2)_3, ..., are 1, 0, 1, 2, 1, 4, 1, 0, 1, 2, 1, 3, 1, 3, ... (OEIS A117971).

Stérin and Woods (2024) constructed a 15-state, 2-symbol Turing machine that starts on a blank tape and halts iff some 2^n with n>8 has no ternary digit 2. The conjecture is thus equivalent to this machine running forever. The Cryptids project (2026) formalized the equivalence in Lean, including the version for Stérin's 14-state Turing machine. The Cryptids project reports assistance from Claude in the formalization and a published build compiling both reductions (Cryptids 2026). The halting behavior of these machines remains open.


See also

Base, Binary, Champernowne Constant, Decimal, Hexadecimal, Octal, Quaternary, Totalistic Cellular Automaton

Portions of this entry contributed by Vincenzo Origlio

Explore with Wolfram|Alpha

References

Cryptids. "Erdős Ternary Turing Machines." 2026. https://github.com/google-deepmind/cryptids/blob/1f9ffee29e707e4d21d19168748c7660a87c608b/Cryptids/Semantics/ErdosTernary15.lean and https://github.com/google-deepmind/cryptids/blob/1f9ffee29e707e4d21d19168748c7660a87c608b/Cryptids/Semantics/ErdosTernary14.lean. https://github.com/google-deepmind/cryptids/pull/19.Erdős, P. and Graham, R. L. Old and New Problems and Results in Combinatorial Number Theory. Geneva, Switzerland: L'Enseignement Mathématique Université de Genève, 1980.Gardner, M. "The Ternary System." Ch. 11 in The Sixth Book of Mathematical Games from Scientific American. Chicago, IL: University of Chicago Press, pp. 104-112, 1984.Knuth, D. E. The Art of Computer Programming. Vol. 2: Seminumerical Algorithms, 3rd ed. Reading, MA: Addison-Wesley, pp. 173-175, 1998.Lauwerier, H. Fractals: Endlessly Repeated Geometric Figures. Princeton, NJ: Princeton University Press, pp. 10-11, 1991.Numberphile. "Beautiful Card Trick." Featuring M. Parker. Nov. 26, 2012. https://www.youtube.com/watch?v=l7lP9y7Bb5g.Numberphile. "The Most Wanted Prime Number." Featuring N. J. A. Sloane. Dec. 15, 2021. https://www.youtube.com/watch?v=vKlVNFOHJ9I.OEIS Foundation. Sequences related to Most Wanted Primes video. https://oeis.org/wiki/Index_to_OEIS:_Section_Mo#MWP.Saye, R. I. "On Two Conjectures Concerning the Ternary Digits of Powers of Two." J. Integer Sequences 25, #22.3.4, 2022. https://cs.uwaterloo.ca/journals/JIS/VOL25/Saye/saye3.pdf.Sloane, N. J. A. "The Persistence of a Number." J. Recr. Math. 6, 97-98, 1973.Stérin, T. and Woods, D. "Hardness of Busy Beaver Value BB(15)." In Proc. 18th International Conference on Reachability Problems (Ed. L. Kovács and A. Sokolova). Cham, Switzerland: Springer, pp. 120-137, 2024. https://doi.org/10.1007/978-3-031-72621-7_9.Sloane, N. J. A. Sequences A007089, A036954, A054635, A102483, A117970, and A117971 in "The On-Line Encyclopedia of Integer Sequences."Vardi, I. "The Digits of 2^n in Base Three." Computational Recreations in Mathematica. Reading, MA: Addison-Wesley, pp. 20-25, 1991.Wolfram, S. A New Kind of Science. Champaign, IL: Wolfram Media, pp. 60-70 and 886, 2002.

Referenced on Wolfram|Alpha

Ternary

Cite this as:

Weisstein, Eric W., with contributions by Vincenzo Origlio. "Ternary." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/Ternary.html

Subject classifications