I am very new to mathematica. I am trying to generate list of number sequence. I want to make 6 sequences. 1 - 10, 10 - 100, 100 - 1 000, 1 000 - 10 000, 10 000 - 100 000. All reversed. Is there any elegant to way how to approach that? I am trying to figure it out using documentation, but I can't. Thanks
1 Answer
$\begingroup$
$\endgroup$
The following uses a combination of Range
and PowerRange
:
Reverse /@ Range @@@ Partition[PowerRange[100000], 2, 1]
Here is an example of output (shortened using Shallow
):
{{10, 9, 8, 7, 6, 5, 4, 3, 2, 1},
{100, 99, 98, 97, 96, 95, 94, 93, 92, 91, <<81>>},
{1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, <<891>>},
{10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, <<8991>>},
{100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, <<89991>>},
}
Range
, i.e. something like this:Range[10, 1, -1]
? You may also be interested inPowerRange
, and combine it withRange
. $\endgroup$seqs = Range[10^Range[0, 4], 10^Range[1, 5]]
. Thenseqs[[1]]
will be your first sequence,seqs[[2]]
the second...Reverse/@seq
will reverse them.rseqs=Range[10^Range[1, 5], 10^Range[0, 4], -1]
will generate them already reversed. $\endgroup$Table[Range[10^(n + 1), 10^n, -10^n], {n, 0, 4}]
Change the steps to-1
if that is what you actually want. $\endgroup$