I apologize in advance for the lack of rigor, as I am not a professional mathematician.
Consider the following array of real numbers: \begin{equation} A_{i_{1},i_{2},\ldots,i_{k}}\in\mathbb{R}^{n_{1}}\otimes\mathbb{R}^{n_{2}}\otimes\ldots\otimes\mathbb{R}^{n_{k}}, \end{equation} where $i_{p}=1,2,\ldots,n_{p}$ are the array indexes, and $p=1,\ldots,k$. I was wondering how to describe such an array with a single index, in other words, to build a one-to-one mapping: \begin{equation} j=j\left(i_{1},i_{2},\ldots,i_{k}\right),\quad j=1,2,\ldots,n, \end{equation} where $n=n_{1}n_{2}\ldots n_{k}$.
This is slightly easier with 0-based indexing. First we start with just $i_1$, $$ i_1 = 0,\dotsc,n_1-1. $$ Then we want to "skip over" every block of $n_1$ indices for $i_2$, thus $$ i_2n_1 + i_1 = \underbrace{0,1,\dotsc,n_1-1}_{\text{$i_2=0$, vary $i_1$}},\underbrace{n_1,n_1+1,\dotsc,2n_1-1}_{\text{$i_2=1$, vary $i_1$}},\dotsc. $$ Extending this idea to all $i_1,\dotsc,i_k$ gives $$ j_0(i_1, \dotsc, i_k) = n_{k-1}n_{k-2}\dotsb n_1i_k + n_{k-2}n_{k-3}\dotsb n_1i_{k-1} + \dotsb + n_2n_1i_3 + n_1i_2 + i_1 $$ for 0-based indexing, and for 1-based indexing we just do $$ j(i_1,\dotsc,i_k) = j_0(i_1-1,\dotsc,i_k-1). $$