A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.
1 of 3

The Highest Dice


Here we have the first 100 items of a sequence:


How is this sequence formed? We first have the number in the range [6, 1] (all possible values of a single dice from highest to lowest). We then have the numbers [66..61, 56..51, 46..41, 36..31, 26..21, 16..11] (all possible concatted values of two dice from highest to lowest). Etc.
This is related to the OEIS sequence A057436: Contains digits 1 through 6 only, but with all the same-digit numbers sorted backwards in the sequence.

The challenge is to choose one of these three options for your function/program with the sequence above:

  1. Take an input \$n\$ and output the \$n\$'th value of this sequence, where it can be either 0-indexed or 1-indexed.
  2. Take an input \$n\$ and output the first \$n\$ or \$n+1\$ values of this sequence.
  3. Output the values from the sequence indefinitely.

Of course, any reasonable output format can be used. Could be as strings/integers/decimals/etc.; could be as an (infinite) list/array/stream/etc.; could be output with space/comma/newline/other delimiter to STDOUT; etc. etc. Please state what I/O and option you're using in your answer!

General rules:

  • This is , so shortest answer in bytes wins.
    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
  • Default Loopholes are forbidden.
  • If possible, please add a link with a test for your code (i.e. TIO).
  • Also, adding an explanation for your answer is highly recommended.

Here some larger test cases if you choose option 1:

n         0-indexed output    1-indexed output

500       5624                5625
750       4526                4531
1000      3432                3433
9329      11111               11112
9330      666666              11111
9331      666665              666666
10000     663632              663633
100000    6131232             6131233