## Synopsis

• Usage:
• Inputs:
• p, an integer, greater than 1; the desired base
• N, an integer, positive; the number whose base $p$ expansion is to be computed
• e, an integer, positive, which specifies how many digits are to be computed
• x, , in the interval [0,1]; the number whose base p expansion is to be computed
• Outputs:
• L1, a list, consisting of all digits of the terminating base p expansion of N
• L2, a list, consisting of the first e digits of the non-terminating base p expansion of x

## Description

adicExpansion(p, 0) returns \{0\}. If $N$ is nonzero, then adicExpansion(p, N) returns a list in which the $i^{th}$ element is the coefficient of $p^{i-1}$ in the base $p$ expansion of $N$.

 i1 : 38 == 3*5^0 + 2*5^1 + 1*5^2 o1 = true i2 : adicExpansion(5, 38) o2 = {3, 2, 1} o2 : List

adicExpansion(p, e, 0) returns a list with $e$ elements, all of which are zero. If $x$ is nonzero, then adicExpansion(p, e, x) returns a list with $e$ elements in which the $i^{th}$ element is the coefficient of $p^{-i}$ in the unique nonterminating base $p$ expansion of $x$. For example, the non-terminating base $3$ expansion of $1/5$ is $1/5 = 0/3 + 1/9 + 2/27 + 1/81 + 0/243 + 1/729 + \cdots$, and so adicExpansion(3, 6, 1/5) returns the digits $0$, $1$, $2$, $1$, $0$, and $1$.

 i3 : adicExpansion(3, 6, 1/5) o3 = {0, 1, 2, 1, 0, 1} o3 : List