2

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

Fyris
  • 23
  • 2
  • 1
    Are you looking for Range, i.e. something like this: Range[10, 1, -1]? You may also be interested in PowerRange, and combine it with Range. – MarcoB Nov 11 '19 at 22:58
  • 1
    seqs = Range[10^Range[0, 4], 10^Range[1, 5]]. Then seqs[[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.

    – ciao Nov 11 '19 at 23:02
  • Table[Range[10^(n + 1), 10^n, -10^n], {n, 0, 4}] Change the steps to -1 if that is what you actually want. – Bob Hanlon Nov 12 '19 at 01:21
  • Thanks for all the help. It helped me. :] – Fyris Nov 12 '19 at 13:00

1 Answers1

2

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>>}, 
}
MarcoB
  • 67,153
  • 18
  • 91
  • 189