[Question]
  [
Here are the first 100 numbers of a sequence:
```
1,2,33,4,55,66,777,8,99,11,111,12,133,141,1515,1,11,18,191,22,222,222,2232,24,252,266,2772,282,2922,3030,31313,3,33,33,335,36,377,383,3939,44,441,444,4443,444,4455,4464,44747,48,499,505,5151,522,5333,5445,55555,565,5757,5855,59559,6060,61611,62626,636363,6,66,66,676,66,666,770,7717,72,737,744,7557,767,7777,7878,79797,88,888,882,8838,888,8888,8886,88878,888,8898,9900,99119,9929,99399,99494,995959,96,979,988,9999,100
```
**How does this sequence work?**
```
n:            1 2  3  4   5   6   7   8    9    10   11   12   13   14   15   16    17
binary:       1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 10000 10001
n extended:   1 22 33 444 555 666 777 8888 9999 1010 1111 1212 1313 1414 1515 16161 17171
1-bit digits: 1 2  33 4   5 5 66  777 8    9  9 1 1  1 11 12   13 3 141  1515 1     1   1
result:       1 2  33 4   55  66  777 8    99   11   111  12   133  141  1515 1     11
```
As you can see, the steps to get the output are as follows:
1. Convert integer \$n\$ to a binary-string.
2. Extend integer \$n\$ to the same length as this binary-string. (I.e. \$n=17\$ is `10001` in binary, which has a length of 5. So we extend the `17` to this same length of 5 by cycling it: `17171`.)
3. Only keep the digits in the extended integer \$n\$ at the positions of the `1`s in the binary-string.
4. Join them together to form an integer*†*.
## Challenge:
One of these options:
1. Given an integer \$n\$, output the \$n^{\text{th}}\$ number in the sequence.
2. Given an integer \$n\$, output the first \$n\$ numbers of this sequence.
3. Output the sequence indefinitely without taking an input ([or by taking an empty unused input](https://codegolf.meta.stackexchange.com/questions/12681/are-we-allowed-to-use-empty-input-we-wont-use-when-no-input-is-asked-regarding)).
## Challenge rules:
* *†*Step 4 isn't mandatory to some extent. You're also allowed to output a list of digits, but you aren't allowed to keep the falsey-delimiter. I.e. \$n=13\$ resulting in `[1,3,3]` or `"1,3,3"` instead of `133` is fine, but `"13 3"`, `[1,3,false,3]`, `[1,3,-1,3]`, etc. is not allowed.
* Although I don't think it makes much sense, with option 1 you are allowed to take a 0-based index \$m\$ as input and output the \$(m+1)^{\text{th}}\$ value.
* If you output (a part of) the sequence (options 2 or 3), you can use a list/array/stream; print to STDOUT with any non-digit delimiter (space, comma, newline, etc.); etc. Your call. If you're unsure about a certain output-format, feel free to ask in the comments.
* Please state which of the three options you've used in your answer.
* The input (with options 1 and 2) is guaranteed to be positive.
* You'll have to support at least the first \$[1, 10000]\$ numbers. \$n=\text{...},9998,9999,10000]\$ result in \$\text{...},9899989,99999999,10010]\$ (the largest output in terms of length within this range is \$n=8191 → 8191819181918\$).
## General rules:
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), 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](https://codegolf.meta.stackexchange.com/questions/2419/default-for-code-golf-program-function-or-snippet/2422#2422) for your answer with [default I/O rules](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods/), so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
* [Default Loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden.
* If possible, please add a link with a test for your code (i.e. [TIO](https://tio.run/#)).
* Also, adding an explanation for your answer is highly recommended.
*PS: For the [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands) code-golfers among us, 4 bytes is possible.*
  
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 72 bytes
```
Pick[Flatten[(i=IntegerDigits)/@Table[#,s=Length[p=#~i~2]]][[;;s]],p,1]&
```
[Try it online!](https://tio.run/##BcHBCoMwDADQXxkIY0Khm1cp9DAGwg4yvIUcMgkxTIPYnP317r2NfOGNXGeqkuqo8w9eK7mzwU3TYM7Cx1NFvbQxT/RdGZpQ0ptNfIE9NaeeHSIC9H1BDHt44LWOh5pfYpaYP2TC0N2x1j8 "Wolfram Language (Mathematica) – Try It Online") 
Here is the plot of the first 30.000 such numbers
[![enter image description here](https://i.stack.imgur.com/uf3rU.png)](https://i.stack.imgur.com/uf3rU.png) 
And here is the Logarithmic plot 
[![enter image description here](https://i.stack.imgur.com/aClD8.png)](https://i.stack.imgur.com/aClD8.png)
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 4 bytes
```
BTịD
```
[Try it online](https://tio.run/##y0rNyan8/98p5OHubpf///@bmgEA), code that computes the \$n\$th term of the sequence, or [check the first 100 terms!](https://tio.run/##y0rNyan8/98p5OHubpf/QYfbHzWtebij5/9/QwMDAA "Jelly – Try It Online")
How it works:
```
B     convert number to binary, i.e. 5 -> [1, 0, 1]
 T    keep the indices of the Truthy elements, i.e. [1, 0, 1] -> [1, 3]
  ị   and then index safely into...
   D  the decimal digits of the input number
```
By "index safely" I mean that indices out of range are automatically converted into the correct range!
[Answer]
# [Python 3](https://docs.python.org/3/), ~~80~~ \$\cdots\$ ~~52~~ 53 bytes
Saved ~~a~~ 2 bytes thanks to [Jitse](https://codegolf.stackexchange.com/users/87681/jitse)!!!  
Saved ~~7~~ 6 bytes thanks to [Surculose Sputum](https://codegolf.stackexchange.com/users/92237/surculose-sputum)!!!  
Added a byte to fix bugs kindly point out by [Jitse](https://codegolf.stackexchange.com/users/87681/jitse) and [Surculose Sputum](https://codegolf.stackexchange.com/users/92237/surculose-sputum).
```
lambda n:[c for c,d in zip(str(n)*n,f'{n:b}')if'0'<d]
```
[Try it online!](https://tio.run/##PYy9boMwGEX3PMVVFtvJ16ofP@FHpWOfoBthIIBbV6lBBoYW8ew0VpUOZzn36gzf00dvw00X5@1af13aGjYvG@jeoaEWxuLHDHKcnLTqYEmLxeaXVSijxZN4bqvNFcubm7t8Fuc5SDgUhNf6Ot5F1Ih152uGunutPLjavneSiVNVHcuUM66oZEJACENCRIhjwulESJKEkBKyjMDsYRAHN/yRI69ivp35b/etfyqV7zAWWhq1w@CMnaTeLyZf8fCCZVyxuNJLIR4/e2PlqFRRdNW6V9sv "Python 3 – Try It Online")
Returns the \$n^{\text{th}}\$ number in the sequence as a list of digits.
[Answer]
# [J](http://jsoftware.com/), ~~13~~ 10 bytes
```
#:##@#:$":
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/la2UlR2UrVSUrP5rcilwpSZn5CsYGgCRio6Ng0asdZqmkoGGoXamnqGBgeZ/AA "J – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 4 bytes
```
×IbÏ
```
[Try it online!](https://tio.run/##yy9OTMpM/f//8HTPpMP9//8bGhkDAA "05AB1E – Try It Online")
Yeah, I found the mysterious 4-byte 05AB1E answer :D
```
×   expand the input digits (input 123 -> 123123123123123... )
Ib  get the binary value of input (123 -> 1111011)
Ï   keep only the digits where the corresponding binary digit is 1
```
[Answer]
# [APL (dzaima/APL)](https://github.com/dzaima/APL), 7 bytes
```
⊤⌿≢∘⊤⍴⍕
```
[Try it online!](https://tio.run/##SyzI0U2pSszMTfyf9qhtgsb/R11LHvXsf9S56FHHDBC7d8uj3qn/Nbke9U0FyqcdWqHwqHezkcF/AA "APL (dzaima/APL) – Try It Online")
### How it works
```
⊤⌿≢∘⊤⍴⍕  ⍝ Input: n
  ≢∘⊤    ⍝ Length of base-2 digits
     ⍴⍕  ⍝ Repeat the digits of n (as a string) to the length of above
⊤⌿       ⍝ Take the digits where the corresponding base-2 digit is 1
```
---
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 16 bytes
```
⍕(∊⊢⊆⍴⍨∘≢)2∘⊥⍣¯1
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT////1HvVI1HHV2PuhY96mp71LvlUe@KRx0zHnUu0jQC0V1LH/UuPrTe8H/ao7YJj3r7HvVN9fR/1NV8aL3xo7aJQF5wkDOQDPHwDP6fdmiFwqPezUYGAA "APL (Dyalog Unicode) – Try It Online")
### How it works
```
⍕(∊⊢⊆⍴⍨∘≢)2∘⊥⍣¯1  ⍝ Input: n
          2∘⊥⍣¯1  ⍝ Binary digits of n
⍕                 ⍝ Stringify n
 (       )        ⍝ Inner function with the two args above
       ∘≢         ⍝ Length of binary digits
     ⍴⍨           ⍝ Cycle the string digits to the length
  ∊⊢⊆             ⍝ Filter the digits by the binary digits
```
[Answer]
# JavaScript (ES6), 55 bytes
```
n=>n.toString(2).replace(/./g,(d,i)=>+d?(n+=[n])[i]:'')
```
[Try it online!](https://tio.run/##HcvLDoJADAXQvV/RBYkzsQ7W92gGV36BS0IC4SWGdAwQN4Rvx2qTezf39JV9sj7vmvewZl@Uc@VmdhGbwT@GruFabbXpyneb5aUKTVijKrDRLloVN8UrF3Oi4ya5LJd6vsaEsEXYIewRDghHhBPCGcEi0EYiOwkgESSExJAg@imyslprz//@f8glC1P57p7lT8XgIsg9974tTetrlQYjT7COIBgrxXpKtZ6/ "JavaScript (Node.js) – Try It Online")
### Commented
```
n =>               // n = input
  n.toString(2)    // convert n to a binary string
  .replace(        // replace:
    /./g,          //   for each
    (d, i) =>      //   digit d at position i:
      +d ?         //     if d is '1':
        (n += [n]) //       coerce n to a string (if not already done)
                   //       and double its size to make sure we have enough digits
        [i]        //       extract the i-th digit
      :            //     else:
        ''         //       discard this entry
  )                // end of replace()
```
[Answer]
# [Python 2](https://docs.python.org/2/), 52 bytes
```
lambda n:[c for c,i in zip(`n`*n,bin(n)[2:])if'0'<i]
```
[Try it online!](https://tio.run/##JcxBDsIgEEDRvaeYsCnY0QA7iPUitUlpFR2jAyHd6OWxjbu/ePn5szwS2xq7S32F93QNwL6fIaYCMxIQw5eyHHncM07EklVv/aAoNro50VA3yBsrge83adAa1f7bOafRaK2N8jvIhXgBRnE4CxTi@EzrLa4/VX8 "Python 2 – Try It Online")
**Input:** An integer \$n\$  
**Output:** The \$n^{th}\$ numbers in the sequence, in the form of a list of digits.
**How:**
* `bin(n)` is the binary string of `n`, e.g `bin(2)` is `"0b10"`. Thus `bin(n)[2:]` is the binary string of `n` without the `0b`.
* ``n`*n` creates the n-extended string by repreating the decimal string of `n` n times. This is longer than needed, but that's ok because extra characters will be truncated later.
* `c,i in zip(`n`*n,bin(n)[2:])` takes each pair of corresponding characters `c,i` from the binary string and the n-extended string.
* `if'0'<i` checks if `i` is the character `"1"`, if so the corresponding character `c` is kept in the result list.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~101~~ \$\cdots\$ ~~96~~ 91 bytes
Save ~~a~~ 6 bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)!!! 
```
b;i;f(n){char s[n];for(b=1;i=n/b;b*=2);for(;b/=2;++i)b&n&&putchar(s[i%sprintf(s,"%d",n)]);}
```
[Try it online!](https://tio.run/##ZYxBDoIwEEX3nGLSBNIKhJQVZqwXQRa0ptqFI6G4Ipy9toorV3/mv3lj6psxIWh0aDmJ1dzHGXxPA9rnzLWS6BQ1GvVBteLToW5Ui2XphC6oKKbXkhzue5f7aXa0WO4rll9ZRWIQuIXH6IiLNYNkRw4OFEiMcQLZIaRXEDHsdnShPgOrnMDYWv7NH70QS/uW/d138igTsnyftvAG "C (gcc) – Try It Online")
Outputs the \$n^{\text{th}}\$ number in the sequence.
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), ~~25~~ 24 bytes
## Code
```
{b←2∘⊥⍣¯1⋄(b⍵)/(⍴b⍵)⍴⍕⍵}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT/8PBNVJj9omGD3qmPGoa@mj3sWH1hs@6m7RSHrUu1VTX@NR71QQ41Hvlke9K4AkSLhWQUHB0hAA "APL (Dyalog Unicode) – Try It Online")
  
  
### Explanation
```
{                                        ⍝ Start function definition
  b ← 2∘⊥⍣¯1                             ⍝ Let b ← binary conversion function
              ⋄                           ⍝ Start new clause
                (b⍵)                      ⍝ Binary representation of ⍵ (input)
                     /                    ⍝ Mask boolean list over following string
                       (⍴b⍵)              ⍝ Length of boolean representation of ⍵
                             ⍴            ⍝ Reshape
                                ⍕⍵        ⍝ Stringify ⍵
                                    }     ⍝ End function definition
```
  
### Binary Conversion
This is all much longer than one would expect from *APL* and is due to the lack of a concise binary conversion function. Unfortunately, the above is the best we can do. Below is the breakdown:
* 'Power' (`⍣`) does an operation *n* times. So `f⍣¯1` calculates the inverse of `f`, if it can.
* 'Decode' (`⊥`) converts from an arbitrary base back to decimal; `2 ⊥ 1 1 0 1` returns `13`.
* 'Jot' (`∘`) can compose two functions as in `(f∘g) 3` or curry as in`(1∘+) 3`.
Together, `2∘⊥⍣¯1` denotes the inverse of the function that converts from binary to decimal.   
(Two left-curried with the encoding function, `2∘⊥`, converts binary to decimal.)
[Answer]
# [Ruby](https://www.ruby-lang.org/), 68 bytes
```
->n{n.to_s(2).gsub(/./).with_index{|b,i|b>?0?(n.to_s*n)[i]:""}.to_i}
```
[Try it online!](https://tio.run/##KypNqvyfpmCr8F/XLq86T68kP75Yw0hTL724NElDX09fU688syQjPjMvJbWiuiZJJ7Mmyc7ewF4DolIrTzM6M9ZKSakWxM2s/c9lqFdaUJKvYWiuqZCSr1CTV8OlAAQFCml6yYk5ORp5mlypeSn/AQ "Ruby – Try It Online")
Returns the **n**th number in the sequence.
---
I'm no expert golfer, so it's undoubtedly possible there's a better Ruby solution, but I'm (not altogether unpleasantly) surprised to see a challenge where Python and JavaScript both outperform Ruby. I guess python's list comprehensions are a perfect fit for this challenge, and JavaScript passing the index as a parameter to the `replace` method is very convenient.
[Answer]
# APL+WIN, 25 bytes
Prompts for integer n and outputs nth term
```
((b⍴2)⊤n)/(b←1+⌊2⍟n)⍴⍕n←⎕
```
[Try it online! Coutesy of Dyalog Classic](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qvz6O2CcZcjzra0/5raCQ96t1ipPmoa0mepj6Q0zbBUPtRT5fRo975eZpAqUe9U/OAgkBt/4Ea/qdxGXKlcRkBsTEQmwCxqQKQMAMR5kBsAcSWQGxoACIMQcKGINWGIOWGIPWGpiDCDESYK4AAAA "APL (Dyalog Classic) – Try It Online")
[Answer]
# [Red](http://www.red-lang.org), 131 bytes
```
func[n][i: 0 remove-each _ t: take/part append/dup t: to""n n |:
length? s: find to""enbase/base to#{}n 2"1"|[s/(i: i + 1) =#"0"]t]
```
[Try it online!](https://tio.run/##HY1BCsIwFET3nmJIN4pIUpcB8Q5uQ5DY/Nig/oY0dWM9e6zdDMwbeJPJ1wt5YzdB1zBxZ9iaqKGQ6TW86UCu63FF0SjuQTK5XOBSIvbST2nlgxAMxqw3T@J76c8YNUJkv07ENzeS/MfSm8@XcRStmM0ot8tRxB7tDqdGKGGLrZkSubLoWqVgUo5cYBhCCwSwtfUH "Red – Try It Online")
[Answer]
# [PHP](https://php.net/), ~~75~~ ~~86~~ ~~81~~ 73 bytes
```
for(;$i<strlen($d=decbin($a=$argn));$i++)if($d[$i])echo$a[$i%strlen($a)];
```
[Try it online!](https://tio.run/##K8go@G9jXwAk0/KLNKxVMm2KS4pyUvM0VFJsU1KTkzKBrERblcSi9DxNTaC0trZmZhpQMlolM1YzNTkjXyURyFSFaUrUjLX@/9/I4l9@QUlmfl7xf103AA "PHP – Try It Online")
Gives the nth number.
Original version didn't handle 0's in input correctly.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 4 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
∍IbÏ
```
**[Try it online!](https://tio.run/##yy9OTMpM/f//UUdvcdLh/v//LQwtDQE "05AB1E – Try It Online")**
### How?
```
∍IbÏ - Full program expecting a single input      e.g. 13    stack:
∍    - extend a to length b (stack empty so a=b=input)       [1313131313131]
 I   - push the input                                        [1313131313131, 13]
  b  - convert to binary                                     [1313131313131, 1101]
   Ï - a where b is 1                                        [133]
     - implicit output                                       133
```
[Answer]
# [Perl 5](https://www.perl.org/) -n, 75 bytes
```
map{$i=0;@b=split//,sprintf"%b",$_;say@s=grep{$b[$i++]}split//,$_ x@b}1..$_
```
[Try it online!](https://tio.run/##K0gtyjH9/z83saBaJdPWwNohyba4ICezRF9fp7igKDOvJE1JNUlJRyXeujix0qHYNr0oFagyKVolU1s7thamVCVeocIhqdZQT08l/v9/E6N/@QUlmfl5xf918/7r@prqGRgaAAA "Perl 5 – Try It Online")
Prints the first `n` numbers in the sequence
# [Perl 5](https://www.perl.org/) -nl, 60 bytes
```
@b=split//,sprintf"%b",$_;say@s=grep{$b[$i++]}split//,$_ x@b
```
[Try it online!](https://tio.run/##K0gtyjH9/98hyba4ICezRF9fp7igKDOvJE1JNUlJRyXeujix0qHYNr0otaBaJSlaJVNbO7YWplQlXqHCIen/fxOjf/kFJZn5ecX/dX1N9QwMDf7r5uUAAA "Perl 5 – Try It Online")
Shorter version that just prints the `n`th number
[Answer]
# [Rust](https://www.rust-lang.org/), ~~131~~ 129 bytes
```
|n|format!("{:b}",n).chars().zip(format!("{}",n).chars().cycle()).flat_map(|(b,c)|if'0'<b{Some(c)}else{None}).collect::<String>()
```
~~[Try it online!](https://tio.run/##VY5BCsIwFET3nuLbTf@HEuy2Wo/gpgeQNCQaSH5LGxea5Ow1giDOcmYeM8tjDZth8NIyEkRwOoDpt8TJTIuXYY9V7MZcNUxC3eWyIomXnfGX/mfqqZxGImGcDFcvZ0w4NoqSNTD2fd3WcZi8RkVZu1XHy8Q6F2xyTqvQdachLJZvZ6QN4LgDKEPAYBlaIfr2UASx2ABz6QXH3wtgkIk@QN7l7Q0 "Rust – Try It Online")~~  
[Try it online!](https://tio.run/##VY5BDoIwFET3nOLLhv8T0sAW0SO44QCmNK02KR9S6kJLz441MTHOcmZeZvxjDbthmKRlJIjgdABz2jfezOwnGQ5Yxm5MZc0k1F36FUm87IK/9D9TT@U0EgnjZLhOcsENx1rRZk3VVP0Yh3nSqChpt@p4mVmnDM3OaRW6rh@Ct3w7I@0AxwIgzwCDZWiFOLVNFsRsAyy5Fxx/D4BBJvoAqUj7Gw "Rust – Try It Online")
Works according to option 1 and returns the \$n^{\text{th}}\$ number of the sequence as a string.
-2 thanks to [Kevin Cruijssen](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen)!
## Explanation
```
|n|                  // Closure taking a parameter n
format!("{:b}",n)    // Binary string of n
.chars()             // Iterate over the chars
.zip(                // Zip iterator with
  format!("{}",n)    //   Decimal string of n
  .chars().cycle()   //   Cycle over the chars
)
.flat_map(           // Map with the following iterator-returning
                     // function and flatten the result
  |(b,c)|            //   Closure taking the char pairs (b,c)
  if'0'<b{Some(c)    //   If '1' then return an iterator yielding c
  else{None}         //   Else return an empty iterator
)
.collect::<String>() // Evaluate into a string
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 79 bytes
```
V;M;r(n){M<=V?r(n/10?:(M*=2,V)),M/=2,M&V&&putchar(n%10+48):0;}f(n){M=1;r(V=n);}
```
[Try it online!](https://tio.run/##TVJLbuMwDN3nFEKBBHbDIqL1r2v0BN5m08micJMZA61bOMlmAp898@jamYp8FEmRFPVpHn43zfW6Leuyz7r8Uj9V22doG9bPj1l9XxW0zXOqN1Dq1Xa1@jqfmj@viFiyXtuYP@pyOIyZFaPEturycri23Ul9vLZdli8uC4Uhjn5/PL@fji87VamLYirIGLLkHHlPIQSKlBIxg4GCGMtsoTp2xONCJE5ILMAzDISlwmFCmSIEKBFIWDXaaDIMIiObjezIeDLYzkSYySSyFsyAzNZMCvqy1osWbCAbyaI7px2hHSaH8s6goEMkzoBBzgPBBXJRrORcIq@9Js8e3fsCRN4IkZdDC4dJkyvQAAfCEYLBhDaCQ7ngg9wPRAyRQgJRjGBBAZjZ@BZeRJh9Sa5VawjmBFmIMEmkTRYSjcLwhLqUokTLM2ithnJxe7wGqNSx/bv/PGTTS@ZqM3sQkk/Rh89eia1aJHCJ6amS9FKt120@hnz/iTE4a5E3W1898g7ZnaoqtXxT6mX5tvvV3dHt67TqQfGO1Jw0TFtmEf9i8v0sIu4b/pf7Ed3vT@e@U7pcDNd/ "C (gcc) – Try It Online")
Generates the nth number
[Answer]
# [Ruby](https://www.ruby-lang.org/), 58 bytes
```
->n{a=n.digits 2;([n]*n*m='').chars{|x|m<<x*(a.pop||0)};m}
```
[Try it online!](https://tio.run/##DcFBDoMgEADAO6/Ym0DSjXrpQelHmh5QtDWRhaAmNq5vR2fS1v3zCAby40WHNYRu@k7rAnUj3/TRpL0pCoX9z6bl4J192@5aWowhMpfqbPyZRYVbXIOsngpcACYWcIswYm/nWZISA7l8AQ "Ruby – Try It Online")
[Answer]
# [Bash](https://www.gnu.org/software/bash/) + GNU utilities, 87 bytes
```
x=$1$1$1$1
for((b=`dc<<<2o$1p`;b;)){ [ $[b] = $b ]&&printf ${x:0:1};x=${x:1};b=${b:1};}
```
[Try the test suite online!](https://tio.run/##NY7NCoMwEITvPsUgQfRQcXupMaYvIoKNP@glEfUgiM@erpbOwvAxh5k1n3X0g1tgMVkclKb0OpGTJEgp88skKGMFQOfYgL4dHR4WobDQb4R3uPbbFYR@14J@F3BvHBvddG1Zlk8naG6UUUlyoIKoTA0NYVBH0bxMdhsgjr3ICjoVdzAyGAZzwen/y@p@xPb@Cw "Bash – Try It Online")
Input \$n\$ is passed as an argument, and the \$n^\text{th}\$ number in the sequence is output on stdout.
How it works:
`x` is set to 4 copies of the input in a row, which is more than enough digits to match the binary equivalent of the input. (A number in base 2 can never be longer than 4 times its representation in base 10, since \$\log\_2(10)<4.\$)
`b` is initialized to the binary representation of the input.
The for loop repeats the following as long as `b` still has at least one `1` in it:
* If `b` doesn't start with a `0`, then the first character in `x` is printed.
* The first character is chopped off of `x` and `b`.
The golfiest trick is probably the way I check to see if `b` starts with a `1`: the expression `$[b]` means: `b` evaluated as an arithmetic expression. This will omit any initial 0s (except that it will keep a final 0 if all the characters in `b` are `0`). So `[ $[b] = b ]` is true iff `b` either starts with a `1` or is equal to `"0"`. But `b` can't equal `"0"` since the loop termination condition would have been true in that case, and the loop would have ended already.
[Answer]
# [Java (JDK)](http://jdk.java.net/), 108 bytes
```
n->{var s=""+n;for(int b=n.highestOneBit(n),i=0;b>0;b/=2,i++)if((b&n)>0)System.out.print((s+=s).charAt(i));}
```
[Try it online!](https://tio.run/##dU7BTsMwDL3vK6xKoIR2oYwbWSoBJw6Iw46IQ9qlnUvrVok7CU379pJNPSFxsJ7tZ7/3Wnu063b/PWM/Dp6hjbOaGDtVT1QxDqTu9Gqcyg4rqDobArxbJDitAJZtYMsRjgPuoY@c2LFHaj6/wPomyOspwOtAYeqd374Ru8b5AmowM62L09F6CCZJUtL14AUSQ2lIHbA5uMAf5F6QBckMTa7LIta92WSYphJrIcpbkkUudz@BXa@GidUYzVmIkJogVXWw/pkFSqnPs74GiR5wNUEw8KAjbCPmeeyi5pIW4K9iLZKbx/0TJBmg1MtRrWxVufFioP/560gs3Hl1qfP8Cw "Java (JDK) – Try It Online")
## Credits
* -7 bytes thanks to Kevin Cruijssen
[Answer]
# [Husk](https://github.com/barbuz/Husk), 5 bytes
```
fḋ¹¢s
```
[Try it online!](https://tio.run/##AR8A4P9odXNr/23Cp2Vz4oKB4bijMTAw/2bhuIvCucKic/// "Husk – Try It Online") This function works according to option 1, outputting the term as a string.
### Explanation
```
fḋ¹¢s  (Let X denote the argument.)
f      Select the elements of
    s    the string representing X,
   ¢    cycled infinitely, corresponding to truthy values of
 ḋ¹     the binary digits of X.
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 8 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
Came up with a few approaches but couldn't do better than 8 bytes.
With output as a digit array:
```
¤¬ðÍ£sgX
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=pKzwzaNzZ1g&input=OTU)
With output as a string:
```
¤ËÍçEgUs
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=pMvN50VnVXM&input=OTU)
```
¤¬ðÍ£sgX     :Implicit input of integer U
¤            :To binary string
 ¬           :Split
  ð          :Truthy indices when
   Í         :  Converted to integer
    £        :Map each X
     s       :  Convert U to string
      gX     :  Get digit at index X
```
```
¤ËÍçEgUì     :Implicit input of integer U
¤            :To binary string
 Ë           :Map each D at index E
  Í          :  Convert D to integer
   ç         :  That many times repeat
    Eg       :  Index E into
      Uì     :  Digit array of U
```
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal) `s`, 17 bytes
```
₌SbL:‟*Ẏf?bZ't;vh
```
[Try it Online!](https://lyxal.pythonanywhere.com?flags=s&code=%E2%82%8CSbL%3A%E2%80%9F*%E1%BA%8Ef%3FbZ%27t%3Bvh&inputs=7&header=&footer=)
A mess.
[Answer]
# [AWK](https://www.gnu.org/software/gawk/manual/gawk.html), 89 bytes
```
{for(f=b=1;$1>=b;e=e$1)c[d++]=and($1,b)/(b*=2);for(;d--;f++)c[d]?g=g substr(e,f,1):0}$0=g
```
[Try it online!](https://tio.run/##Fcq9DkAwEADgVzF0aLXCSQxcjgcRg9OfQUJSxCCeveKbv/leU3r8HqUnJkABPTE6cgLUMlqtJ5o3KwUYVqXknGqF/0ZbFOi1/tM0BArZcfFxRumMN6C66hUVhZSa9gM "AWK – Try It Online")
Not that short, but AWK doesn't have a `print` format to generate binary strings from integers, so it has to iterate to get that info...
At a high level, one loop uses bitwise `and` operations with a single bit moved one position to the left each time to built an array of "binary" settings. It also builds up a string composed of multiple copies of the `N` number while it's looping. AWK doesn't have a nice `string*number` operator either.
Then the second loop works backwards through that array and for each entry which is `1`, it appends the appropriate character to a "results" accumulator.
The final step just prints the accumulated string.
```
# Loop 1, build the "binary" array and string of duplicated "N" characters
for(f=b=1;$1>=b;e=e$1)c[d++]=and($1,b)/(b*=2);
   (f=b=1;                                     # Loop init, "f" is used in loop #2
          $1>=b;                               # Exit test, goes until bit check > N
                e=e$1)                         # End of loop, build "N dup string
                      c[d++]=and($1,b)/(b*=2); # Body, does a couple of things...
                                               # d++ : increment bit position
                                               # and($1,b) : extract bit
                                               # /(b*=2) : normalize, then shift bit
                                               # c[d++]= : add to "binary" array
# Loop 2, accumulate chars associated with set bits
for(;d--;f++)c[d]?g=g substr(e,f,1):0
     d--;                             # Exit test, when all bits checked stop
         f++)                         # End of loop, increment char pos in "N" dup str
             c[d]?                 :  # Ternary, code runs if bit is set
                  g=g substr(e,f,1)   # Append current char to accumulator
                                    0 # No-op "else" from ternary
# Print the result
$0=g   # Typical AWK golf trick, assign "$0" to what you want to print w/o code block
```
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 11 bytes
```
⭆↨Ｉθ²⎇ι§θκω
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRCO4BEil@yYWaDglFqdqOCcWl2gUauooGAFxSGpRXmJRpUamjoJjiWdeSmqFRqGOQjZQplxTU9P6/39D4/@6ZTkA "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
   θ        Input as a string
  Ｉ         Cast to integer
 ↨  ²       Convert to base `2`
⭆           Map over digits
      ι     Current digit
     ⎇      If non-zero
        θ   Input as a string
       §    Cyclically indexed by
         κ  Current index
          ω Else empty string
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 6 bytes
The `Ï<` ruins the consecutive word `bāsè`... (If you don't get it, the hex code 05AB1E converted to base64 would result in `base`.)
```
bāsÏ<è
```
[Try it online!](https://tio.run/##yy9OTMpM/f8/6Uhj8eF@m8Mr/v@3MLQ0BAA "05AB1E – Try It Online")
# Explanation
```
b      To base 2
 ā     Length-range to 1
  s    Prepend
   Ï   Keep all that's truthy
    <  -1 due to 0-based indexing ... that's terrible!
     è Modular Indexing
```
]