Ternary

Author

Eric W. Weisstein
April 6, 2006

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Numbers/Ternary.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/Ternary.html.

©2006 Wolfram Research, Inc. except for portions noted otherwise

Enumeration

ternary=Table[IntegerDigits[n,3],{n,0,10}]

Flatten[ternary]

Graphical Representation

Ternary[{min_,max_},len_]:=Module[{n},
Table[IntegerDigits[n,3,len],{n,min,max}]
]

Ternary[{0,3^3-1},3]

NaryPlot[3,3^3-1,{5,1},-.4]

d in (Subscript[((2^n)), 3])

Table[BaseForm[2^n,3],{n,10}]//ColumnForm

All

digits=Table[Reverse@IntegerDigits[2^n,3],{n,10^3}];//Timing

digits=Table[Reverse@IntegerDigits[2^n,3],{n,10^4}];//Timing

digits=Table[Reverse@IntegerDigits[2^n,3],{n,10^5}];//Timing

Counts

digitcounts=Transpose[Table[DigitCount[2^n,3],{n,10^4}]];//Timing

digitcounts=Transpose[Table[DigitCount[2^n,3],{n,10^5}]];//Timing

digitcounts=Transpose[Table[DigitCount[2^n,3],{n,10^6}]];//Timing

Missing Given Digits

Length/@digitcounts

0

Take[(l0=Flatten[Position[#,0,1,1]&/@digits/.{}->0]),100]//Timing

Position[digitcounts[[-1]],0]//Flatten

1

Take[(l1=Flatten[Position[#,1,1,1]&/@digits/.{}->0]),100]//Timing

Position[digitcounts[[1]],0]//Flatten

2

Take[(l2=Flatten[Position[#,2,1,1]&/@digits/.{}->0]),100]//Timing

Position[digitcounts[[2]],0]//Flatten