0
$\begingroup$

I want to write a program in Mathematica which for an input $n$ gives me a representation in a number system of base 26. For example, $$1419=2\cdot 26^2+2\cdot 26+15.$$

The output I am looking for is the list $\{2,2,15\}$.

$\endgroup$
  • 6
    $\begingroup$ IntegerDigits[1419, 26] $\endgroup$ – BlacKow Apr 6 '17 at 19:18
4
$\begingroup$

Alternatively to IntegerDigits you can "write a program" yourself. Something like this will work for positive numbers:

sillyIntegerDigits[n_, base_] := First@Transpose@Reverse@Rest@
   NestWhileList[{Mod[#[[2]], base], Floor[#[[2]]/base]} &, {1,n}, #[[2]] > 0&];

sillyIntegerDigits[1419, 26]
(* {2, 2, 15} *)
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.