# Tag Info

2

This should get you closer BaseExponent[ a_. Power[b_, e_]] := ({a^(1/e) b, e} /. {a2_. Power[b2_, e2_], e3_} :> {a2^(1/e2) b2, e3*e2}) BaseExponent[a_Integer] := {a, 1} BaseExponent[a_Rational] := {a, 1} BaseExponent[a_. Complex[r_, i_]] := {a Complex[r, i], 1} (* EDIT: added per evansdoe comment *) And @@ { BaseExponent[(1 + I ...

5

Here is another way to generate ternary number strings of a certain length. ternaryStrings[len_Integer?Positive] := StringJoin @@@ Map[ToString, Tuples[{0, 1, 2}, len], {2}] With this ternaryStrings[1] {"0", "1", "2"} ternaryStrings[2] {"00", "01", "02", "10", "11", "12", "20", "21", "22"} ternaryStrings[3] {"000", "001", "002", ...

4

n = 3; list = Tuples[{0, 1, 2}, n]; To get numbers rather than lists of digits: list2 = FromDigits /@ list (* {0, 1, 2, 10, 11, 12, 20, 21, 22, 100, 101, 102, 110, 111, 112, 120, 121, \ 122, 200, 201, 202, 210, 211, 212, 220, 221, 222} *) Or BaseForm[#, 3] & /@ Range[0, 3^n - 1] To pad with leading 0's IntegerString[#, 3, n] & /@ ...

Top 50 recent answers are included