text:
Print a list of iPhones
Write the shortest program that prints, in order, a complete list of iPhone iterations, according to this site:
iPhone
iPhone 3G
iPhone 3GS
iPhone 4
iPhone 4S
iPhone 5
iPhone 5c
iPhone 5s
iPhone 6
iPhone 6 Plus
iPhone 6s
iPhone 6s Plus
iPhone SE
iPhone 7
iPhone 7 Plus
iPhone 8
iPhone 8 Plus
iPhone X
iPhone XR
iPhone XS
iPhone XS Max
iPhone 11
iPhone 11 Pro
iPhone 11 Pro Max

Output should be printed exactly as specified, though trailing newlines are allowed (as well as additional whitespace at the end of each line).
This is code golf, so the shortest answer in bytes, per language, wins.

Note that this is about 87 bytes using naive compression.

Possible duplicate of We're no strangers to code golf, you know the rules, and so do I

@pppery I would say it's just different enough not to be a dupe.

I disagree; the fact that only one answer beats Bubblegum is evidence that the text doesn't have enough structure for specialized compression algorithms to beat generic ones.

@pppery I admit the answers can't be as interesting as I though, but that's not necessarily grounds for closing/duping, right?

I am not going to vote to close but I don't see anything that this challenge provides that is not provided by the dupe target.

@pppery The canvas answer is pretty cool.

Iphone 12s needed now?

Android is better <3

@JairoA.delRio The quality's comparable, Apple's just overprices stuff :p

Canvas, 77 76 73 bytes
¶＋∔ｉＦ╴qV1┼#│»ｌN↶:╋KＡRV／＋├6<∔ZK＠≠≡Ｚｅ３ｈ}s×⁴＊⁵GZX─?ep┼Q‟-ｓ｛iPhone ×|∙ Plus╋］

Try it here!
-3G-3GS-4-4S-5-5c-5s-6-6|-6s-6s|-SE-7-7|-8-8|-X-XR-XS-XS Max-11-11 Pro-11 Pro Max compressed, split on -, | replaced with ' Plus', and 'iPhone ' prepended.

Wow, this beats the Bubblegum solution!

Zsh, 107 105 bytes
-2 bytes due to leniency on trailing spaces
print -l iPhone\ {,{3G,4}{,S},5{,c,s},6{,s}{,\ Plus},SE,{7,8}{,\ Plus},X{,R,S,S\ Max},11{,\ Pro{,\ Max}}}

Try it online!
Try it online!
A long brace expansion. Bash/sh need printf %s\\n instead for 4 extra bytes.

Not necessarily. I just came up with a Bash answer that's the same size (but it uses less strict output rules).

Ah, the "as well as additional whitespace at the end of each line" wasn't allowed when I posted.

JavaScript (ES6),  137 136  135 bytes
_=>"iPhone3G9GS39S33c9s3303s9s01SE3903301X1XR1XS1XS Max22 Pro2 Pro Max".replace(/\d/g,n=>[" Plus",k=`
iPhone `,k+11,k+i][n]||k+i++,i=3)

Try it online!
How?
The numeric version is stored in a counter \$i\$ initialized to \$3\$.
Below are the digits used for the compression:

\$0\$: " Plus"
\$1\$: "\n" + "iPhone "
\$2\$: "\n" + "iPhone 11"
\$3\$: "\n" + "iPhone " + \$i\$
\$9\$: same as \$3\$, but \$i\$ is incremented afterwards

Resulting in:
"iPhone"    --> "iPhone"
"3G"        --> "iPhone 3G"
"9GS"       --> "iPhone 3GS" (i++)
"3"         --> "iPhone 4"
"9S"        --> "iPhone 4S" (i++)
"3"         --> "iPhone 5"
"3c"        --> "iPhone 5c"
"9s"        --> "iPhone 5s" (i++)
"3"         --> "iPhone 6"
"30"        --> "iPhone 6 Plus"
"3s"        --> "iPhone 6s"
"9s0"       --> "iPhone 6s Plus" (i++)
"1SE"       --> "iPhone SE"
"3"         --> "iPhone 7"
"90"        --> "iPhone 7 Plus" (i++)
"3"         --> "iPhone 8"
"30"        --> "iPhone 8 Plus"
"1X"        --> "iPhone X"
"1XR"       --> "iPhone XR"
"1XS"       --> "iPhone XS"
"1XS Max"   --> "iPhone XS Max"
"2"         --> "iPhone 11"
"2 Pro"     --> "iPhone 11 Pro"
"2 Pro Max" --> "iPhone 11 Pro Max"

///, 108 bytes
Naive compression, simply replacing # with \niPhone. (Further compression does not work by the way.)
/#/
iPhone //@/ Plus/iPhone#3G#3GS#4#4S#5#5c#5s#6#6@#6s#6s@#SE#7#7@#8#8@#X#XR#XS#XS Max#11#11 Pro#11 Pro Max

Try it online!
///, 103 bytes
This works only if preceding newlines are allowed.
/#/
iPhone //@/ Plus/##3G#3GS#4#4S#5#5c#5s#6#6@#6s#6s@#SE#7#7@#8#8@#X#XR#XS#XS Max#11#11 Pro#11 Pro Max

Try it online!

05AB1E, 81 bytes
11”3G3GS44S55c5s66‰´6s6s‰´SE77‰´88‰´XXRXSXSî£ÿÿˆ×ÿˆ×î£”•ΛΩ&°ŽäÞнã•0šTª£'i”ƒ¿ ”«ì»

Try it online!
I dom't have time to re-analyze.
Original Solution, 178 bytes
'i”ƒ¿”«D… 3G«D'S«.ÀD.Á„ 4«D'S«.ÀD.Á„ 5«Ð'c«s's«.ÀD.Á„ 6«D" Plus"D.Á«sDŠ's«D.À«.ÀD.Á… SE«.ÀD.Á„ 7«D" Plus"D.Á«.À.ÀD.Á„ 8«DŠs«.ÀD.Á„ X«Ð'R«s'S«D" Max"D.Á«.À.ÀD.Á… 11«DŠ" Pro"«DŠs«»

Try it online!
Explanation
First, I push the string "iPhone" by using 'i”ƒ¿”«.
I duplicate that, and push " 3G", and concatenate them to get "iPhone 3G".
After that, I use .ÀD.Á to get "iPhone" at the top of the stack, etc.
When I get to iPhone 6, I put " Plus" at the bottom of the stack and save it for iPhone 6S Plus.
I don't save it for iPhone 7 and 8 Plus, because I'm not sure if it will golf off some bytes, and I'd already spent enough time figuring it out.
I did save " Max" though, and I'm pretty sure now that saving " Plus" would've shaved off more bytes. However, now that the program is already completed, it's unclear how I do that.
At the end, I concatenate the whole stack together with newline delimiters, and implicit output happens.

84B.

80

This is missing iPhone 6s and iPhone 6s Plus, as are all the suggested edits (the 178 is fine) :(

@ExpiredData This is missing iPhone 6s & Plus (as well as mine). Quick fix of 89 bytes

@ExpiredData Your 85-byter is missing the leading iPhone (and I'm not sure leading newlines are allowed either). Here an easy fix that's still 85 bytes, though. PS: If your 85-byter would have worked, you could have dropped the ) to join the stack directly.

82 bytes

81 bytes. Now you're below the new Bubblegum answer. ;)

80 bytes. If you want me to include an explanation, or perhaps post it as a separated answer, lmk.

Jelly, 83 bytes
“Ø^ÞṠṠẠ'Ḣß¥»=⁶œṗ;11;“RcGEs436X578 ”µ“ƈ`¿øÐ⁽ḞÆCḊḋɲÑF×GÇz ⁸¦MƊ‘×“£¿Þç‘¦5ŻṃµṚ“®Ɲ,»,K)Y

Try it online!
How?
Uses eighteen non-"iPhone " parts and constructs each line from a big-endian number in base eighteen, then prefixes each with "iPhone " and joins with newline characters.
The parts used are (comma separated):
 Max, Plus, Pro, ,S,R,c,G,E,X,s,3,4,5,6,7,8,11
The mapping to the eighteen digits was chosen so that:

the space character is a zero - allowing a single byte prepend-zero to make the first line
no two digit "numbers" are greater than 255 - allowing encoding with code-page indices
the three digit "numbers" (S,G,3;  Plus,s,6;  Max,S,X; and  Max, Pro,11) are all exact multiples of five (and less than 1275) - allowing encoding with code-page indices, with post multiplication to acquire their full value
the three words are adjacent and do not occupy digit one - allowing compression with a split-before spaces application

One such (1-indexed) ordering is:
S, Max, Plus, Pro,11,R,c,G,E,s,4,3,6,X,5,7,8,
As such the code works like so:
“...»=⁶œṗ;11;“...”µ“...‘×“£¿Þç‘¦5ŻṃµṚ“®Ɲ,»,K)Y - Main Link: no arguments
“...»                                          - string = "S"+" Max"+" Plus"+" Pro"
      ⁶                                        - space character
     =                                         - equals? (vectorises)
       œṗ                                      - partition before truthy indices
         ;11                                   - concatenate 11
             “...”                             - list of characters "RcGEs436X578 "
            ;                                  - concatenate
                                               - giving our "digits" [1,2,...,17,0]
                  µ                            - start a new monadic chain
                   “...‘                       - list of code-page indices = [156, 96, 11, 29, 15, 141, 195, 13, 67, 193, 233, 163, 16, 70, 17, 71, 14, 122, 32, 136, 5, 77, 145]
                               ¦               - sparse application...
                                               - ...to indices:
                         “£¿Þç‘                -   code-page indices = [2, 11, 20, 23]
                        ×       5              - ...do: multiply by five -> [156, 480, 11, 29, 15, 141, 195, 13, 67, 193, 1165, 163, 16, 70, 17, 71, 14, 122, 32, 680, 5, 77, 725]
                                 Ż             - prepend a zero
                                  ṃ            - base-decompress (convert to base-18 using the "digits")
                                               -   e.g. 680 -> [2, 1, 14] -> [" Max",'S','X']
                                   µ        )  - for each:
                                    Ṛ          -   reverse it (e.g. [" Max",'S','X'] -> ['X','S'," Max"])
                                     “®Ɲ,»     -   string = "iPhone"
                                          ,    -   pair
                                           K   -   join with a space character
                                             Y - join with newline characters
                                               - implicit, smashing print

Bubblegum, 82 bytes
00000000: cb0c c8c8 cf4b e582 500a c6ee 0856 308c  .....K..P....V0.
00000010: 6902 67c0 854c e18c 6438 ab18 c632 8333  i.g..L..d8...2.3
00000020: 1402 724a 11c2 482c 1489 6057 18cb 1cce  ..rJ..H,..`W....
00000030: 4051 6001 67a0 0847 c019 4170 5630 82a5  @Q`.g..G..ApV0..
00000040: e09b 5801 e319 1a22 580a 0145 f9a8 3c90  ..X...."X..E..<.
00000050: 4a00                                     J.

Try it online!
Bubblegum, 87 bytes
Written by @FryAmTheEggman, so I don't take credit for this.
00000000: e001 0700 4f5d 0034 9409 072b 9ed9 334a  ....O].4...+..3J
00000010: 2d4f 957c 30d4 5ae8 8bc7 1c12 f267 7c2c  -O.|0.Z......g|,
00000020: 47df 6d0b 6d45 b174 dcab 2da7 e97a ed9f  G.m.mE.t..-..z..
00000030: e772 808d f6c6 d93e c423 2b3c 378e 0a13  .r.....>.#+<7...
00000040: c57b 7a72 436d a362 6818 88d0 a495 4466  .{zrCm.bh.....Df
00000050: e336 dcfb ac00 00                        .6.....

Try it online!

82 bytes, generated with zopfli.

Perl 5, 118 114 bytes
$_="3G3GS44S55c5s66-6s6s-SE77-88-XXRXSXS Max99Pro9Pro Max";s/-/ Plus/g;s/^|(\d|X|SE)/\niPhone $1/g;s/9/11 /g;print

Try it online!
This code is rather simple: in the string $_, it replaces "-" with " Plus".  Then it cuts the string at every digit, "X" or "SE" and prefixes the matching part with a line break and "iPhone ".  Finally, it replaces "9" by "11 ".
Attempting to replace " Max" or " Pro" with shorter symbols would not bring any benefits because the substitution would cost more characters.
Thanks to Weizel who allowed me to save 4 bytes by replacing the first "iPhone" in the string.
I assumed that the final newline was not necessary.

Last line is not required to end with a newline (-:

Add line beggining sarch in this substitution s/^|(\d|X|SE)/\niPhone $1/g. It allows to cut 'iPhone' in the main string and saves 4 bytes.

Keg, 129 127 bytes
‘1⊙‘®p`iPhone `:&
⑻3G
⑻3GS
⑻4
⑻4S
⑻5
⑻5c
⑻5s
⑻6
⑻6 ©p
⑻6s
⑻6s ©p
⑻SE
⑻7
⑻7 ©p
⑻8
⑻8 ©p
⑻X
⑻XR
⑻XS
⑻XS Max
⑻11
⑻11 Pro
⑻11 “∂⬭q≥

Try it online!
How's that for a submission! Simply using the register and a little bit of string compression + variables gives a kind of competitive answer.

Retina 0.8.2, 91 bytes

¶3G¶3GS¶4¶4S¶5¶5c¶5s¶6=¶6s=¶SE¶7=¶8=¶X¶XR¶XS!¶11¶11 Pro!
%(`^
iPhone
!
¶$` Max
=
¶$` Plus

Try it online! Includes additional whitespace on the first line Explanation:

¶3G¶3GS¶4¶4S¶5¶5c¶5s¶6=¶6s=¶SE¶7=¶8=¶X¶XR¶XS!¶11¶11 Pro!

Insert the names of the models, but without iPhone, Max or Plus, which get added later.
%(`

Operate on each line individually.
^
iPhone

Prefix iPhone to the line.
!
¶$` Max

If the line has a !, then duplicate it and append Max to the duplicate.
=
¶$` Plus

If the line has a =, then duplicate it and append Plus to the duplicate.

Bash, 109 bytes
printf %s\\n iPhone\ {,{3G,4}{,S},5{,c,s},6{,s}{,\ Plus},SE,{7,8}{,\ Plus},X{,R,S,S\ Max},11{,\ Pro{,\ Max}}}

Similar to the Zsh solution but some slight changes and some output leniency.
Try it online!

−1 byte (108)

Swift, 152 bytes
",3G,3GS,4,4S,5,5c,5s,6,6 Plus,6s,6s Plus,SE,7,7 Plus,8,8 Plus,X,XR,XS,XS Max,11,11 Pro,11 Pro Max".split(separator: ",").forEach{print("iPhone \($0)")}

Being related to iPhones, this needs an answer in Swift. Unfortunately Swift is woooordy. The most boring route is the shortest :/
Try it online

Brain-Flak, 5007 bytes
((((((<(((((((((<((((((((((<((((((((<(((((((((<((((((((<(((((((((<(((((((<(<((((((((<((((((((<((((<(((((((<(<(((((((<(<((((<((((((<((<((((((<(<((((((<(<(((<<((<((<((<(((((<((<((((<((((((<(<(<((((<((<((((((<((<((<((<(((((<(<(<(((((((((((((<((<(<(<<((((((<((<(((<((((((()(()(()()()){}){}){}){}){})[()(()(()()()()[]){}){}])[((()()()[]){}){}])>((((()[]){}){}){})()(()(()(()([]){}){}){}){})()()())[(()(()()[]){}){}])>(((()[]){}){})()([]){}))>(()()([])({}){})(()([]){})({}){})()(()()()()){})())[()(()()()){}])[(((()()()){}){}){}])()()()()()()()()()[])>((()()()()()){})>((()([]){})({}){})()()())>((([]){}){})[(()()()[]){}])>(()(()()[]){}))[()((()()()()){}){}])>(()(([]){}){})()(()()()()){})())[()(()()()){}])[(((()()()){}){}){}])()(((()()()){}){}){})[()()([])({}){}])()()()()()()()[]))[()((()()()()){}){}])()((()((()()()()){}){}){}){})()(()()()()){})())[()(()()()){}])>((()[]){})()(((()()()){}){}){})>((()()()()()){})(()()()()()()()()()()()()()[]){})>(()(()()()()()[]){})[((()()()()()){}){}])[[]])()()()()()[])()()()()())[()()()()()()()()[]])>(()(()[]){})()(()()()()){})())>(([]){})[(((()()()){}){}){}])()(((()()()){}){}){})>((()()()()()){})()(((()(()()()()){}){}){}){})()()()()())>((((()()()()){}){}){})()()()()()()()()()()[])()(()()()()){})())[()(()()()){}])[(((()()()){}){}){}])()(((()()()){}){}){})>((()()()()()){})()()()()()()[])(()()()){})>((((()()()()){}){}){})[])()(()()()()){})())[()(()()()){}])>(()()()()()()()[])()(((()()()){}){}){})>((()()()()()){})()()[])>((((()()()()){}){}){})()((()((()()()()){}){}){}){})()(()()()()){})())[()(()()()){}])[(((()()()){}){}){}])()(((()()()){}){}){})>((()()()()()){})()(((()((()()()){}){}){}){}){})()())[()(()()()()){}])[((()(()()()){}){}){}])>((((()()()()){}){}){})(((()()()){}){}){})[(((()()()){}){}){}])>(()()()()()()()()()[])()(()()()()){})())[()(()()()){}])[(((()()()){}){}){}])()(((()()()){}){}){})>((()()()()()){})(()(()(()()()()()){}){}){})[(((()()()){}){}){}])>([])()(()()()()){})())>([])[(((()()()){}){}){}])()(((()()()){}){}){})>((()()()()()){})>(()()()()()()()[])()())[()(()()()()){}])[((()(()()()){}){}){}])>((((()()()()){}){}){})()(()(()()()()()){}){})>((((()()()()){}){}){})()((()((()()()()){}){}){}){})()(()()()()){})())[()(()()()){}])[(((()()()){}){}){}])()(((()()()){}){}){})>((()()()()()){})()((()(()()()()()){}){}){})>((((()()()()){}){}){})()((()((()()()()){}){}){}){})()(()()()()){})())[()(()()()){}])[(((()()()){}){}){}])()(((()()()){}){}){})>((()()()()()){})()(()((()(()()()){}){}){}){})(()(()()()){}){})>((((()()()()){}){}){})()((()((()()()()){}){}){}){})()(()()()()){})())[()(()()()){}])[(((()()()){}){}){}])()(((()()()){}){}){})>((()()()()()){})()(((()((()()()){}){}){}){}){})()())[()(()()()()){}])[((()(()()()){}){}){}])>((((()()()()){}){}){})()(()(((()()()()()){}){}){}){})>((()(()((()()()){}){}){}){})[(()(()()()()()){}){}])()((()((()()()()){}){}){}){})()(()()()()){})())[()(()()()){}])[(((()()()){}){}){}])()(((()()()){}){}){})>((()()()()()){})()(((()((()()()){}){}){}){}){})>((()(()((()()()){}){}){}){})[(()(()()()()()){}){}])()((()((()()()()){}){}){}){})()(()()()()){})())[()(()()()){}])[(((()()()){}){}){}])()(((()()()){}){}){})>((()()()()()){})()(((()((()()()){}){}){}){}){})()())[()(()()()()){}])[((()(()()()){}){}){}])>((((()()()()){}){}){})(()(()()()()()){}){})[(()(()()()()()){}){}])()((()((()()()()){}){}){}){})()(()()()()){})())[()(()()()){}])[(((()()()){}){}){}])()(((()()()){}){}){})>((()()()()()){})((()(()()()()()){}){}){})[(()(()()()()()){}){}])()((()((()()()()){}){}){}){})()(()()()()){})())[()(()()()){}])[(((()()()){}){}){}])()(((()()()){}){}){})>((()()()()()){})()(((()((()()()){}){}){}){}){})>(()((()((()()()){}){}){}){})[()((()()()()()){}){}])()((()((()()()()){}){}){}){})()(()()()()){})())[()(()()()){}])[(((()()()){}){}){}])()(((()()()){}){}){})>((()()()()()){})()(((()(()()()()()){}){}){}){})[(()(()(()()()()()){}){}){}])[()((()()()()()){}){}])()((()((()()()()){}){}){}){})()(()()()()){})())[()(()()()){}])[(((()()()){}){}){}])()(((()()()){}){}){})>((()()()()()){})()(()((()()()()()){}){}){})[()((()()()()()){}){}])()((()((()()()()){}){}){}){})()(()()()()){})())[()(()()()){}])[(((()()()){}){}){}])()(((()()()){}){}){})>((()()()()()){})()(((()(()()()()){}){}){}){})[()(()(()(()()()){}){}){}])[((()()()()()){}){}])()((()((()()()()){}){}){}){})()(()()()()){})())[()(()()()){}])[(((()()()){}){}){}])()(((()()()){}){}){})>((()()()()()){})(()((()()()()()){}){}){})[((()()()()()){}){}])()((()((()()()()){}){}){}){})()(()()()()){})())[()(()()()){}])[(((()()()){}){}){}])()(((()()()){}){}){})>((()()()()()){})()(((()(()()()()){}){}){}){})[((()()()){}){}])[((()()()()()){}){}])[()(()(()()()()){}){}])()((()((()()()()){}){}){}){})()(()()()()){})())[()(()()()){}])[(((()()()){}){}){}])()(((()()()){}){}){})>((()()()()()){})()((()(()(()()()){}){}){}){})[((()()()()()){}){}])[()(()(()()()()){}){}])()((()((()()()()){}){}){}){})()(()()()()){})())[()(()()()){}])[(((()()()){}){}){}])()(((()()()){}){}){})>((()()()()()){})()(()((()(()()()()()){}){}){}){})()(()()()()){})())[()(()()()){}])[(((()()()){}){}){}])()(((()()()){}){}){})

Try it online!
Created using this program

Deadfish, 2374 bytes
{{i}}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}i}dc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}dc{i}{i}c{{d}iiii}dc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}dc{i}{i}c{i}iic{{d}iii}dddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}c{{d}iiiiii}ddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}c{i}{i}{i}ic{{d}iii}dddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}ic{{d}iiiiii}dddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}ic{{i}dddddd}iiiiiic{{d}i}ic{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}ic{{i}dddd}iic{{d}}dddddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}iic{{d}iiiiii}ddddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}iic{d}{d}ddc{{i}ddddd}ddc{i}{i}{i}ddc{i}dcddc{{d}}dddddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}iic{{i}dddd}ic{{d}}dddddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}iic{{i}dddd}ic{{d}ii}dddc{{i}ddddd}ddc{i}{i}{i}ddc{i}dcddc{{d}}dddddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{{i}ddddd}ic{d}ddddc{{d}iiii}ic{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}iiic{{d}iiiiii}dddddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}iiic{d}{d}dddc{{i}ddddd}ddc{i}{i}{i}ddc{i}dcddc{{d}}dddddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}iiiic{{d}iiiiii}ddddddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}iiiic{d}{d}ddddc{{i}ddddd}ddc{i}{i}{i}ddc{i}dcddc{{d}}dddddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{{i}ddddd}iiiiiic{{d}ii}iic{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{{i}ddddd}iiiiiicddddddc{{d}iii}ddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{{i}ddddd}iiiiiicdddddc{{d}iii}dddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{{i}ddddd}iiiiiicdddddc{{d}iiiii}dc{{i}dddddd}iiiiic{i}{i}c{i}{i}iiic{{d}}{d}c{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}dddcc{{d}iiiiii}ic{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}dddcc{d}{d}iiic{{i}ddddd}ddc{i}{i}{i}iiiicdddc{{d}}dc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}dddcc{d}{d}iiic{{i}ddddd}ddc{i}{i}{i}iiiicdddc{{d}ii}ic{{i}dddddd}iiiiic{i}{i}c{i}{i}iiic

Umm...

Vyxal jr, 96 93 bytes
` «₍
`\Y`
3G
3GS
4
4S
5
5c
5s
6
6Y6s
6sYSE
7
7Y8
8YX
XR
XS
XS ½…
11
11 ×Ǐ
11 ×Ǐ ½…`V↵ƛ`i¬Ẋ `+

Try it Online!
Compressed  Plus with a newline a bit.

Python 3, 136 bytes
for i in",3G,3GS,4,4S,5,5c,5s,6,6 Plus,6s,6s Plus,SE,7,7 Plus,8,8 Plus,X,XR,XS,XS Max,11,11 Pro,11 Pro Max".split(","):print("iPhone",i)

Try it online!

APL (dzaima/APL), 139 bytes
⎕←↑('iPhone ',)¨" ""3G""3GS""4""4S""5""5c""5s""6""6 Plus""6s""6s Plus""SE""7""7 Plus""8""8 Plus""X""XR""XS""XS Max""11""11 Pro""11 Pro Max"

I do not think there is a way to "bond" similar to J's n&u. That would be an obvious way to save some bytes.
This is my first APL answer. I probably should've gone with something a little less trivial.
Attempt This Online!

Vyxal jr, 88 bytes
`3G3GS44S55c5s66 «₍6s6s «₍SE77 «₍88 «₍XXRXSXS ½…1111 ×Ǐ11 ×Ǐ ½…`»∵Te§ḋƒꜝL⁼»f₀pẇ¤J`i¬Ẋ `+

Try it Online!

As opposed to Vyxal senior.

Stax, 100 bytes
Yay, I (finally) beat Zsh!
┌W○εRKW>◙≡D↨u^╬=Θs╜i^░δ#(\D╘i╗◄⌠╜`┌!║Æ♂∞╦J╘^╙üÜ°¢╠╣⌂ƒ♣↨←Bµ☻òK$▲,0fε▄PÉ↔ΓÅ▲s2îùvπ↑╛!╢╠♣=·F┴²C6µób└╢íf

Run and debug it
Explanation

Repace all A's in the compressed string with "".
Surround it with ".
Evaluate the string.
Wrap the output in a list.
Map every item  with a preceding iPhone. Print with a newline.

R, 175 178 bytes
cat(paste('iPhone',c('','3G','3GS','4','4S','5','5c','5s','6','6 Plus','6s','6s Plus','SE','7','7 Plus','8','8 Plus','X','XR','XS','XS Max','11','11 Pro','11 Pro Max')),sep='\n')

Try it online!
Manual is shorter than this programmatic take:
R, 231 bytes
r=rep;b='';m='Plus';cat(paste("iPhone",paste0(r(c(b,3:6,'SE',7:8,'X',11),c(1,2,2,3,3,1,2,2,4,3)),c(b,'G','GS',b,'S',b,'c','s',b,'s','s',r(b,6),'R','S','S',r(b,3))),c(r(b,9),m,b,m,b,b,m,b,m,r(b,3),'Max',b,'Pro','Pro Max')),sep='\n')

Try it online!

First answer doesn't seem to include the original iPhone?

@Neil whoops, fixed thanks

write and rbind save 3 bytes: Try it online! I may come back and tinker with the numerals a little more; I do think it can be shortened somehow.

note that write is just a wrapper to cat so it can sometimes be shorter if you know the options :-)

Batch, 156 Bytes
@ECHO(iPhone&For %%A In (3G 3GS 4 4S 5 5c 5s 6 6s "6 Plus" "6s Plus" SE 7 "7 Plus" 8 "8 Plus" X XR XS "XS Max" 11 "11 Pro" "11 Pro Max")do @Echo(iPhone %%~A

T-SQL, 145 bytes:
SELECT'iPhone '+value
FROM string_split(' -3G-3GS-4-4S-5-5c-5s-6-6 Plus-6s-6s Plus-SE-7-7 Plus-8-8 Plus-X-XR-XS-XS Max-11-11 Pro-11 Pro Max','-')

I did find a shorter version using a simple string replacement (128 bytes), but it's not quite as interesting, and it's not clear whether the preceding line break is allowed:
PRINT REPLACE('223G23GS2424S2525c25s2626 Plus26s26s Plus2SE2727 Plus2828 Plus2X2XR2XS2XS Max211211 Pro211 Pro Max',2,'
iPhone ')

I used the numeral (2) as the replacement character so I don't have to include another set of quotes.

Ruby, 129 bytes
$><<"iPhone:3G:3GS:4:4S:5:5c:5s:6:6 Plus:6s:6s Plus:SE:7:7 Plus:8:8 Plus:X:XR:XS:XS Max:11:11 Pro:11 Pro Max".gsub(?:,"
iPhone ")

Try it online!
Uses the fact that strings can have newlines in (one byte), rather than \n (two bytes).
Otherwise this is a simple replacement of a single-character string into iPhone

PowerShell, 108 bytes
'3G,3GS,4,4S,5,5c,6,6 Plus,SE,7,7 Plus,8,8 Plus,X,XR,XS,XS Max,11,11 Pro,11 Pro Max'-split','|%{"iPhone $_"}

Try it online!
-30 bytes for mazzy

108 bytes

@mazzy thx learnt new trick ;-)

Stax, 92 bytes
Ωî♂∞¥■J⌡┤≥♦C♀ç¿kë▀/∞♥╧0î·Φ│∟/╢ì☼αuèôΩY?╘÷▄òà╣○╢{⌂P○å§o\τ+ mδ↓ê☻.═+Ä{╜A2jJü7πP|è╡╖Rä►┴Luƒ☺/¬&

Run and debug it
simplifying the existing answer was enough for 92. there's probably a way to compress the intial over-big string.

JavaScript (Node.js), 132 bytes
_=>'iPhone,3G,3GS,4,4S,5,5c,5s,6,6 Plus,6s,6s Plus,SE,7,7 Plus,8,8 Plus,X,XR,XS,XS Max,11,11 Pro,11 Pro Max'.split`,`.join`
iPhone `

Try it online!
-5 bytes thanks to @cairdcoinheringaahing and @RedwolfPrograms

Sequences, \$118 \log_{256}(96) \approx 97.1\$ bytes
",3G,3GS,4,4S,5,5c,5s,6,6 Plus,6s,6s Plus,SE,7,7 Plus,8,8 Plus,X,XR,XS,XS Max,11,11 Pro,11 Pro Max"","p{H"iPhone "fhF}

Explanation
"..."","p{H"iPhone "fhF}
"..."                    // Push a string of suffixes of the models of iPhones
     ","p                // Split by commas
         {             } // For each model:
          H"iPhone "f    //   Print "iPhone " with no trailing newline
                     hF  //   And print the suffix with a trailing newline

Screenshot

C (gcc), 162 bytes
f(i,n){n="3G3GS44S55c5s66 Plus6s6s PlusSE77 Plus88 plusXXRXSXS Max1111 Pro11 Pro Max";for(i=24;i--;)printf("iPhone %s\n",n+=strlen(n++));}

-1 byte thanks to Neil!
-45 bytes thanks to dzaima!
Try it online!

207 bytes

162 bytes

C# (Visual C# Interactive Compiler), 123 bytes
Write("iPhone,3G,3GS,4,4S,5,5c,6,6 Plus,SE,7,7 Plus,8,8 Plus,X,XR,XS,XS Max,11,11 Pro,11 Pro Max".Replace(",","\niPhone "))

Try it online!
C# (Visual C# Interactive Compiler), 131 chars, 154 bytes
foreach(var x in"ȔДȥ͖˶ଇ˷೷աଈ	ଉ\0΀Ƞਠࡼၼ")WriteLine($"iPhone {x%16-1:0;X;.}"+" GS Max Pro Maxs PluscSER".Substring(x/16%32,x>>9));

Though it isn't the shortest, I invested quite a lot of effort and it would be a shame to just toss it all away.
Note: There is a null byte in the string, but I can't copy-paste it so it's represented by \0 in the code.
Try it online!

I think you could use Write instead of WriteLine. If a trailing newline is needed, a \n i still shorter than WriteLine

Pyth, 103 bytes
j"
iPhone "[kk"3G""3GS"4"4S"5"5s""5c"6+6J" Plus"="6s"+GJ"SE"7+7J8+8~J" Max"\X"XR"K"XS"+KJ11="11 Pro"+bJ

Today I learned about the ~.
Try it online!

authors: J. А. del Rio - слава СССР


text:
Convert a string to upper case without using built in methods/functions
Challenge
You will be given a string as an argument. You need to convert that string to upper case. But you can't  use any built in method or function nor any external programs.
Rule
No use of built in methods or functions or external programs. Only arithmetic, bitwise, logical operators, regex, replace, split, join, ASCII codes are allowed.
Input
The string as an argument. The string can contain spaces and special characters.
Output
The string in upper case.
This is code-golf so shortest code wins.

Does "one two" become "One two", "One Two", or "ONE TWO"?

"ONE TWO" @Want

Can contain spaces and special characters : does that include code points $\ge127$?

We can assume that any keyboard is acceptable?

@ouflak I'm pretty sure it only uses letters, so yes.

Huh, so the input is only spaces and special characters are present in the input? How do you define special characters?

No everyting can be present in the string. Sorry I was stuck in a problem for several hours so I couldn't respond. Please reopen the question. Thanks!

Would this be a good [tag:atomic-code-golf] question?

Can you specify what characters can be in the input, and give some examples of input to output? How can you ban built-in functions and then list several operations that are typically functions in most languages?

I still think this question is unclear.  What is allowed and not allowed is only vaguely explained.  But additionally since special characters must be supported it is unclear what characters need to be made "upper case" and what that means.  E.g. do we need to make á into Á?

Are \u and \U disallowed as builtins or allowed as regexes in s/.+/\U$0/?

Japt, 5 bytes
;dCíB

Try it here

@Downvoters, please have the decency to leave I comment!

Batch, 245 116 Bytes
@Set v=%~1
@for %%A in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)do @call set v=%%v:%%A=%%A%%
@ECHO(%v%

Somewhat ugly and brute forced, using a for loop to enact substring modification on each instance of a character.
129 bytes dropped thanks to Neil

Hey thanks for submission. It works, but it's way too long (245 bytes!)

indeed, but that's batch. no means within the language of batch to shorten it further. (I have 0 expectations of providing the shortest answer)

@set/pv= is a slightly golfier way to take input.

Substring replacement is case-insensitive in Batch, so you can simply use @for %%A in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)do @call set v=%%v:%%A=%%A%% (using call also removes the need to enable delayed expansion).

One of those little details I clean forgot. Answer updated.

Turing Machine Code, 279 bytes
0 q Q r 0
0 w W r 0
0 e E r 0
0 r R r 0
0 t T r 0
0 y Y r 0
0 u U r 0
0 i I r 0
0 o O r 0
0 p P r 0
0 a A r 0
0 s S r 0
0 d D r 0
0 f F r 0
0 g G r 0
0 h H r 0
0 j J r 0
0 k K r 0
0 l L r 0
0 z Z r 0
0 x X r 0
0 c C r 0
0 v V r 0
0 b B r 0
0 n N r 0
0 m M r 0
0 _ _ r 0
0 * * r 0

Try it online!

Keg, 14 bytes
(&az⑻•[& -|&],

Try it online!
Finally! A challenge Keg was designed for! This utilises the fact that a) subtracting 32 from the ordinal value of any lower-case letter gives its upper-case counterpart and b) characters are treated as numbers when arithmetic is applied.
The unicode part is to ensure the letter is in the lower case range, without using built-ins.

Hey @Downvoters, at least be courteous enough to leave a comment explaining what y'all think is wrong here.

Erlang (escript), 56 bytes
Numeric lists are strings in Erlang. (9 bytes away from C, let's see if I can get this shorter.)
f([H|T])->[H-if H>97,H<122->32;1<2->0end]++f(T);f(N)->N.

Try it online!
Explanation
f([H | T]) -> % Try to split the input into head & tail
[H -          % Subtract the current item by:
if
  H > 97, H < 122 -> 32;
              % If the item's ord code is in the lowercase letter range:Return 32
  1 < 2 -> 0  % Otherwise, return 0. 1<2 is 1 byte shorter than true.
end
] ++ f(T);    % Concatenate with the uppercased tail

f(N) -> N.    % If the tail is the null list (i.e. it can't be splitted):
              % Return this operand.
```

05AB1E, 8 5 bytes
(Once again, a'_' uses something that I didn't know even existed in 05AB1E.)
AžpR‡

Explanation
       # Implicit input
A      # Push lowercase alphabet
 žp    # Push uppercase alphabet reversed
   R   # And reverse it again
    ‡  # Transliterate
     J # Join list

Try it online!
Original solution without ‡, 19 18 bytes
εDAskD®ÊižpRèës}}J

Try it online!
Explanation
                   # Implicit input
ε               }  # Loop on each character
εD              }  # Duplicate
ε A             }  # Push lowercase alphabet
ε  s            }  # Swap
ε   k           }  # Find index of character in alphabet
ε    D          }  # Duplicate for comparison
ε     ®         }  # Push -1 (see link below)
ε      Ê        }  # Check if equal
ε       i    ë }}  # If-else statement
ε       ižp  ë }}  # Push uppercase alphabet in reverse
ε       i  R ë }}  # Reverse the string (so now it's just the uppercase alphabet)
ε       i   èë }}  # Index the uppercase alphabet
ε       i    ës}}  # Swap to get character
                 J # Join all the items

If you're wondering why ® returns -1, go here

5B. (Ab)uses the transliteration.

FYI I can do it without transliteration in 13 bytes: εDAus«sAskè}J.

@Neil this uses the built-in u, making it invalid. 14 bytes using žpR instead of Au.

4, 54 bytes
Thanks to @PkmnQ for pointing out the bug!
3.6993269897697017008003010098801100009960100950070094

Try it online!
4, 28 bytes (old answer, only supports lower case and nothing else XD)
3.69932700800100009950070094

Try it online!

Cool, but if you input a capital letter it becomes gibberish.

Welp, fix is underway

Bash + core utilities, 10 bytes
tr a-z A-Z

Try it online!

C (gcc), 47 45 bytes
Saved 2 bytes thanks to ceilingcat!!!

f(char*s){for(;*s;++s)*s^=*s>96&*s<123?32:0;}

Try it online!

@ceilingcat That's the way to golf if statement followed by assignment - thanks! :-)

APL+WIN, 28 bytes
Prompts for string:
⎕av[i-32×(i←⎕av⍳⎕)∊(97+⍳26)]

Converts string to relevant indices in APL's atomic vector, identifies indices of lower case letters, decrements only those indices by 32 and converts resulting string back to characters.

@a'_'  Not sure. The rules state ascii codes are supported and that is effectively what is in the APL atomic vector.

Charcoal, 9 bytes
⭆Ｓ§⁺αι⌕βι

Try it online! Link is to verbose version of code. Only 7 bytes longer than the built-in! Explanation:
 Ｓ          Input string
⭆           Map over characters and join
      ⌕     Find index in
       β    Lowercase alphabet of
        ι   Current character
  §         Cyclically index into
   ⁺        Concatenation of
    α       Uppercase alphabet
     ι      Current character
            Implicitly print

If the input character is not found in the lowercase alphabet, the returned index is -1, which represents the last character when passed to the cyclic index function.

Retina, 5 bytes
T`l`L

Try it online!
Transliterate lower case letters into upper case Letters.

16/32/64-bit x86 assembly language, 17 bytes
AC    l1: lodsb
3C 61     cmp   al, 'a'
72 06     jb    l2
3C 7A     cmp   al, 'z'
77 02     ja    l2
24 DF     and   al, 0dfh ;convert to uppercase
AA    l2: stosb
84 C0     test  al, al
75 F0     jne   l1
C3        ret
Call with (r/e)si pointing to source string, (r/e)di to destination buffer to hold converted text.

why was this downvoted? This seems like a perfectly valid answer to me. Oh well, at least I can help get you back up to 0...

Right, yes.  I was 6502 coding right before that.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Convert a decimal integer to binary only using arithmetic operators
There are 10 types of people in the world, those who understand binary and those who do not.
Where are you? Let's see!
Challenge
Your task is to convert a decimal integer to binary, only using a set of arithmetic operators (+, -, *, / and %). You can use conditional statements, loops and variables. (No bitwise operator/No Builtin methods or function).
Input
A decimal integer.
Output
The binary number.
Examples
2 -> 10
6 -> 110
etc...

The shortest code wins.

What is the largest integer that we have to support?

I take it that / is integer (floored) division? When you say we can use conditional statements, can these include operators like == and >?

Honestly, I think the only way to unambiguously define what constructs are allowed would be to fully specify your own mini-language, defining all operators within it and how they work , and require that answers be in it, [tag:atomic-code-golf]-style.

Are we allowed to have leading 0s? I.e. 000110 instead of 110?

No, you are not allowed to have leading zeros.

Yes arithmetic and logical operators supported @xnor

What is the smallest integer that we have to support?

Is concatenation operator allowed? If not I'll delete my answer..

Does the value returned have to be a numeric value, or can it be a string representing the binary value?

Don't really understand why the VTC went through without any comments (apart from @xnor) to explain to OP what was wrong. I have VTO'ed. I quite like the challenge. OK it needs clarification but downvotes and VTCs without an explanation in the comments don't help OP make it better.

Can we have leading zeroes in the output?

What counts as a loop? Does map or reduce? If I have an operator that takes a start point, transition and a condition and repeats the transition until the condition is met, is that a loop? I interpreted the spec as to mean bitwise operators, built-in methods or functions are banned, but everything else is fine, but other people have interpreted it as only arithmetic operators, conditional statements, loops and variables are allowed. Which one is it?

I wouldn't have guessed that (recursive) function calls, which many of the answers use, would be allowed from what the challenge says.

Is assignment not allowed (rules out recursive functions)? How about increment (++)? Are numeric literals banned? How can I do IO if I can't use the input/output commands? Are non-pure arithmetic operators (like +=) allowed? Honestly, I think there's more than enough ambiguities to be reclosed as unclear.

Python 2, 30 bytes
f=lambda n:n and n%2+10*f(n/2)

Try it online!

JavaScript (Node.js), 28 bytes
f=x=>x?x%2+10*f((x-x%2)/2):x

Try it online!

Suggest x/2|0 instead of (x-x%2)/2 for -4 bytes : Try it online!

C (gcc), 50 27 26 bytes
f(n){n=n?n%2+10*f(n/2):n;}

Try it online!

Whitespace, 141 bytes
[S S S T    N
_Push_1][S N
S _Dupe_1][T    N
T   T   _Read_STDIN_as_integer][T   T   T   _Retrieve_input][S N
S _Dupe_input][N
S S N
_Create_Label_LOOP][S N
S _Dupe_top][N
T   S S N
_If_0_Jump_to_Label_LOOP2][S S S T  N
_Push_1][T  S S T   _Subtract][S N
T   _Swap_top_two][S N
S _Dupe_top][S S S T    S N
_Push_2][T  S T T   _Modulo][S N
T   _Swap_top_two][S S S T  S N
_Push_2][T  S T S _Integer_divide][S T  S S T   S N
_Copy_0-based_2nd][N
S N
N
_Jump_to_Label_LOOP][N
S S S N
_Create_Label_LOOP2][S N
T   _swap_top_two][S S S T  N
_Push_1][S N
S _Dupe_1][T    T   T   _Retrieve_input][T  S S T   _Subtract][T    S S S _Add][N
T   S T N
_If_0_Jump_to_Label_DONE][S S S T   S T S N
_Push_10][T S S N
_Multiply][T    S S S _Add][N
S N
S N
_Jump_to_Label_LOOP2][N
S S T   N
_Create_Label_DONE][T   N
S T _Print_as_integer_to_STDOUT]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.
Try it online (with raw spaces, tabs and new-lines only).
Funny thing is, is that I can use everything Whitespace has to offer for this challenge. So even if builtins were allowed, this would still be the approach to use, since Whitespace has none. ;)
Explanation in pseudo-code:
Integer input = read STDIN as integer
Integer index = input
Integer b = input
Start LOOP:
  If(index == 0):
    Jump to LOOP2
  index = index - 1
  Integer a[index] = b[previous_index] modulo-2
  Integer b[index] = b[previous_index] integer-divided by 2
  Go to next iteration of LOOP

Start LOOP2:
  If(index+1 == input):
    Jump to DONE
  a = a + b*10
  Go to next iteration of LOOP2

Label DONE:
  Print a as integer to STDOUT
  (stop program implicitly with an error)

Example run: input = 6
Command  Explanation                 Stack                             Heap  STDIN STDOUT

SSST     Push 1                      [1]
SNS      Duplicate top (1)           [1,1]
TNTT     Read STDIN as integer       [1]                               {1:6} 6
TTT      Retrieve input from heap    [6]                               {1:6}
SNS      Duplicate top (6)           [6,6]                             {1:6}
NSSN     Create Label LOOP           [6,6]                             {1:6}
 SNS      Duplicate top (6)          [6,6,6]                           {1:6}
 NTSSN    If 0: Jump to Label LOOP2  [6,6]                             {1:6}
 SSSTN    Push 1                     [6,6,1]                           {1:6}
 TSST     Subtract (6-1)             [6,5]                             {1:6}
 SNT      Swap top two               [5,6]                             {1:6}
 SNS      Duplicate top (6)          [5,6,6]                           {1:6}
 SSSTSN   Push 2                     [5,6,6,2]                         {1:6}
 TSTT     Modulo (6%2)               [5,6,0]                           {1:6}
 SNT      Swap top two               [5,0,6]                           {1:6}
 SSSTSN   Push 2                     [5,0,6,2]                         {1:6}
 TSTS     Integer-divide (6//2)      [5,0,3]                           {1:6}
 STSSTSN  Copy 0-based 2nd (5)       [5,0,3,5]                         {1:6}
 NSNN     Jump to Label LOOP         [5,0,3,5]                         {1:6}

 SNS      Duplicate top (5)          [5,0,3,5,5]                       {1:6}
 NTSSN    If 0: Jump to Label LOOP2  [5,0,3,5]                         {1:6}
 SSSTN    Push 1                     [5,0,3,5,1]                       {1:6}
 TSST     Subtract (5-1)             [5,0,3,4]                         {1:6}
 SNT      Swap top two               [5,0,4,3]                         {1:6}
 SNS      Duplicate top (3)          [5,0,4,3,3]                       {1:6}
 SSSTSN   Push 2                     [5,0,4,3,3,2]                     {1:6}
 TSTT     Modulo (3%2)               [5,0,4,3,1]                       {1:6}
 SNT      Swap top two               [5,0,4,1,3]                       {1:6}
 SSSTSN   Push 2                     [5,0,4,1,3,2]                     {1:6}
 TSTS     Integer-divide (3//2)      [5,0,4,1,1]                       {1:6}
 STSSTSN  Copy 0-based 2nd (4)       [5,0,4,1,1,4]                     {1:6}
 NSNN     Jump to Label LOOP         [5,0,4,1,1,4]                     {1:6}

 SNS      Duplicate top (4)          [5,0,4,1,1,4,4]                   {1:6}
 NTSSN    If 0: Jump to Label LOOP2  [5,0,4,1,1,4]                     {1:6}
 SSSTN    Push 1                     [5,0,4,1,1,4,1]                   {1:6}
 TSST     Subtract (4-1)             [5,0,4,1,1,3]                     {1:6}
 SNT      Swap top two               [5,0,4,1,3,1]                     {1:6}
 SNS      Duplicate top (1)          [5,0,4,1,3,1,1]                   {1:6}
 SSSTSN   Push 2                     [5,0,4,1,3,1,1,2]                 {1:6}
 TSTT     Modulo (3%2)               [5,0,4,1,3,1,1]                   {1:6}
 SNT      Swap top two               [5,0,4,1,3,1,1]                   {1:6}
 SSSTSN   Push 2                     [5,0,4,1,3,1,1,2]                 {1:6}
 TSTS     Integer-divide (1//2)      [5,0,4,1,3,1,0]                   {1:6}
 STSSTSN  Copy 0-based 2nd (3)       [5,0,4,1,3,1,0,3]                 {1:6}
 NSNN     Jump to Label LOOP         [5,0,4,1,3,1,0,3]                 {1:6}

 SNS      Duplicate top (3)          [5,0,4,1,3,1,0,3,3]               {1:6}
 NTSSN    If 0: Jump to Label LOOP2  [5,0,4,1,3,1,0,3]                 {1:6}
 SSSTN    Push 1                     [5,0,4,1,3,1,0,3,1]               {1:6}
 TSST     Subtract (3-1)             [5,0,4,1,3,1,0,2]                 {1:6}
 SNT      Swap top two               [5,0,4,1,3,1,2,0]                 {1:6}
 SNS      Duplicate top (0)          [5,0,4,1,3,1,2,0,0]               {1:6}
 SSSTSN   Push 2                     [5,0,4,1,3,1,2,0,0,2]             {1:6}
 TSTT     Modulo (0%2)               [5,0,4,1,3,1,2,0,0]               {1:6}
 SNT      Swap top two               [5,0,4,1,3,1,2,0,0]               {1:6}
 SSSTSN   Push 2                     [5,0,4,1,3,1,2,0,0,2]             {1:6}
 TSTS     Integer-divide (0//2)      [5,0,4,1,3,1,2,0,0]               {1:6}
 STSSTSN  Copy 0-based 2nd (2)       [5,0,4,1,3,1,2,0,0,2]             {1:6}
 NSNN     Jump to Label LOOP         [5,0,4,1,3,1,2,0,0,2]             {1:6}

 SNS      Duplicate top (2)          [5,0,4,1,3,1,2,0,0,2,2]           {1:6}
 NTSSN    If 0: Jump to Label LOOP2  [5,0,4,1,3,1,2,0,0,2]             {1:6}
 SSSTN    Push 1                     [5,0,4,1,3,1,2,0,0,2,1]           {1:6}
 TSST     Subtract (2-1)             [5,0,4,1,3,1,2,0,0,1]             {1:6}
 SNT      Swap top two               [5,0,4,1,3,1,2,0,1,0]             {1:6}
 SNS      Duplicate top (0)          [5,0,4,1,3,1,2,0,1,0,0]           {1:6}
 SSSTSN   Push 2                     [5,0,4,1,3,1,2,0,1,0,0,2]         {1:6}
 TSTT     Modulo (0%2)               [5,0,4,1,3,1,2,0,1,0,0]           {1:6}
 SNT      Swap top two               [5,0,4,1,3,1,2,0,1,0,0]           {1:6}
 SSSTSN   Push 2                     [5,0,4,1,3,1,2,0,1,0,0,2]         {1:6}
 TSTS     Integer-divide (0//2)      [5,0,4,1,3,1,2,0,1,0,0]           {1:6}
 STSSTSN  Copy 0-based 2nd (1)       [5,0,4,1,3,1,2,0,1,0,0,1]         {1:6}
 NSNN     Jump to Label LOOP         [5,0,4,1,3,1,2,0,1,0,0,1]         {1:6}

 SNS      Duplicate top (1)          [5,0,4,1,3,1,2,0,1,0,0,1,1]       {1:6}
 NTSSN    If 0: Jump to Label LOOP2  [5,0,4,1,3,1,2,0,1,0,0,1]         {1:6}
 SSSTN    Push 1                     [5,0,4,1,3,1,2,0,1,0,0,1,1]       {1:6}
 TSST     Subtract (1-1)             [5,0,4,1,3,1,2,0,1,0,0,0]         {1:6}
 SNT      Swap top two               [5,0,4,1,3,1,2,0,1,0,0,0]         {1:6}
 SNS      Duplicate top (0)          [5,0,4,1,3,1,2,0,1,0,0,0,0]       {1:6}
 SSSTSN   Push 2                     [5,0,4,1,3,1,2,0,1,0,0,0,0,2]     {1:6}
 TSTT     Modulo (0%2)               [5,0,4,1,3,1,2,0,1,0,0,0,0]       {1:6}
 SNT      Swap top two               [5,0,4,1,3,1,2,0,1,0,0,0,0]       {1:6}
 SSSTSN   Push 2                     [5,0,4,1,3,1,2,0,1,0,0,0,0,2]     {1:6}
 TSTS     Integer-divide (0//2)      [5,0,4,1,3,1,2,0,1,0,0,0,0]       {1:6}
 STSSTSN  Copy 0-based 2nd (0)       [5,0,4,1,3,1,2,0,1,0,0,0,0,0]     {1:6}
 NSNN     Jump to Label LOOP         [5,0,4,1,3,1,2,0,1,0,0,0,0,0]     {1:6}

 SNS      Duplicate top (1)          [5,0,4,1,3,1,2,0,1,0,0,0,0,0,0]   {1:6}
 NTSSN    If 0: Jump to Label LOOP2  [5,0,4,1,3,1,2,0,1,0,0,0,0,0]     {1:6}
NSSSN    Create Label LOOP2          [5,0,4,1,3,1,2,0,1,0,0,0,0,0]     {1:6}
 SNT      Swap top two               [5,0,4,1,3,1,2,0,1,0,0,0,0,0]     {1:6}
 SSSTN    Push 1                     [5,0,4,1,3,1,2,0,1,0,0,0,0,0,1]   {1:6}
 SNS      Duplicate top (1)          [5,0,4,1,3,1,2,0,1,0,0,0,0,0,1,1] {1:6}
 TTT      Retrieve input from heap   [5,0,4,1,3,1,2,0,1,0,0,0,0,0,1,6] {1:6}
 TSST     Subtract (1-6)             [5,0,4,1,3,1,2,0,1,0,0,0,0,0,-5]  {1:6}
 TSSS     Add (0+-5)                 [5,0,4,1,3,1,2,0,1,0,0,0,0,-5]    {1:6}
 NTSTN    If 0: Jump to Label DONE   [5,0,4,1,3,1,2,0,1,0,0,0,0]       {1:6}
 SSSTSTSN Push 10                    [5,0,4,1,3,1,2,0,1,0,0,0,0,10]    {1:6}
 TSSN     Multiply (0*10)            [5,0,4,1,3,1,2,0,1,0,0,0,0]       {1:6}
 TSSS     Add (0+0)                  [5,0,4,1,3,1,2,0,1,0,0,0]         {1:6}
 NSNSN    Jump to Label LOOP2        [5,0,4,1,3,1,2,0,1,0,0,0]         {1:6}

 SNT      Swap top two               [5,0,4,1,3,1,2,0,1,0,0,0]         {1:6}
 SSSTN    Push 1                     [5,0,4,1,3,1,2,0,1,0,0,0,1]       {1:6}
 SNS      Duplicate top (1)          [5,0,4,1,3,1,2,0,1,0,0,0,1,1]     {1:6}
 TTT      Retrieve input from heap   [5,0,4,1,3,1,2,0,1,0,0,0,1,6]     {1:6}
 TSST     Subtract (1-6)             [5,0,4,1,3,1,2,0,1,0,0,0,-5]      {1:6}
 TSSS     Add (0+-5)                 [5,0,4,1,3,1,2,0,1,0,0,-5]        {1:6}
 NTSTN    If 0: Jump to Label DONE   [5,0,4,1,3,1,2,0,1,0,0]           {1:6}
 SSSTSTSN Push 10                    [5,0,4,1,3,1,2,0,1,0,0,10]        {1:6}
 TSSN     Multiply (0*10)            [5,0,4,1,3,1,2,0,1,0,0]           {1:6}
 TSSS     Add (0+0)                  [5,0,4,1,3,1,2,0,1,0]             {1:6}
 NSNSN    Jump to Label LOOP2        [5,0,4,1,3,1,2,0,1,0]             {1:6}

 SNT      Swap top two               [5,0,4,1,3,1,2,0,0,1]             {1:6}
 SSSTN    Push 1                     [5,0,4,1,3,1,2,0,0,1,1]           {1:6}
 SNS      Duplicate top (1)          [5,0,4,1,3,1,2,0,0,1,1,1]         {1:6}
 TTT      Retrieve input from heap   [5,0,4,1,3,1,2,0,0,1,1,6]         {1:6}
 TSST     Subtract (1-6)             [5,0,4,1,3,1,2,0,0,1,-5]          {1:6}
 TSSS     Add (1+-5)                 [5,0,4,1,3,1,2,0,0,-4]            {1:6}
 NTSTN    If 0: Jump to Label DONE   [5,0,4,1,3,1,2,0,0]               {1:6}
 SSSTSTSN Push 10                    [5,0,4,1,3,1,2,0,0,10]            {1:6}
 TSSN     Multiply (0*10)            [5,0,4,1,3,1,2,0,0]               {1:6}
 TSSS     Add (0+0)                  [5,0,4,1,3,1,2,0]                 {1:6}
 NSNSN    Jump to Label LOOP2        [5,0,4,1,3,1,2,0]                 {1:6}

 SNT      Swap top two               [5,0,4,1,3,1,0,2]                 {1:6}
 SSSTN    Push 1                     [5,0,4,1,3,1,0,2,1]               {1:6}
 SNS      Duplicate top (1)          [5,0,4,1,3,1,0,2,1,1]             {1:6}
 TTT      Retrieve input from heap   [5,0,4,1,3,1,0,2,1,6]             {1:6}
 TSST     Subtract (1-6)             [5,0,4,1,3,1,0,2,-5]              {1:6}
 TSSS     Add (2+-5)                 [5,0,4,1,3,1,0,-3]                {1:6}
 NTSTN    If 0: Jump to Label DONE   [5,0,4,1,3,1,0]                   {1:6}
 SSSTSTSN Push 10                    [5,0,4,1,3,1,0,10]                {1:6}
 TSSN     Multiply (0*10)            [5,0,4,1,3,1,0]                   {1:6}
 TSSS     Add (1+0)                  [5,0,4,1,3,1]                     {1:6}
 NSNSN    Jump to Label LOOP2        [5,0,4,1,3,1]                     {1:6}

 SNT      Swap top two               [5,0,4,1,1,3]                     {1:6}
 SSSTN    Push 1                     [5,0,4,1,1,3,1]                   {1:6}
 SNS      Duplicate top (1)          [5,0,4,1,1,3,1,1]                 {1:6}
 TTT      Retrieve input from heap   [5,0,4,1,1,3,1,6]                 {1:6}
 TSST     Subtract (1-6)             [5,0,4,1,1,3,-5]                  {1:6}
 TSSS     Add (3+-5)                 [5,0,4,1,1,-2]                    {1:6}
 NTSTN    If 0: Jump to Label DONE   [5,0,4,1,1]                       {1:6}
 SSSTSTSN Push 10                    [5,0,4,1,1,10]                    {1:6}
 TSSN     Multiply (1*10)            [5,0,4,1,10]                      {1:6}
 TSSS     Add (1+10)                 [5,0,4,11]                        {1:6}
 NSNSN    Jump to Label LOOP2        [5,0,4,11]                        {1:6}

 SNT      Swap top two               [5,0,11,4]                        {1:6}
 SSSTN    Push 1                     [5,0,11,4,1]                      {1:6}
 SNS      Duplicate top (1)          [5,0,11,4,1,1]                    {1:6}
 TTT      Retrieve input from heap   [5,0,11,4,1,6]                    {1:6}
 TSST     Subtract (1-6)             [5,0,11,4,-5]                     {1:6}
 TSSS     Add (4+-5)                 [5,0,11,-1]                       {1:6}
 NTSTN    If 0: Jump to Label DONE   [5,0,11]                          {1:6}
 SSSTSTSN Push 10                    [5,0,11,10]                       {1:6}
 TSSN     Multiply (11*10)           [5,0,110]                         {1:6}
 TSSS     Add (1+10)                 [5,110]                           {1:6}
 NSNSN    Jump to Label LOOP2        [5,110]                           {1:6}

 SNT      Swap top two               [110,5]                           {1:6}
 SSSTN    Push 1                     [110,5,1]                         {1:6}
 SNS      Duplicate top (1)          [110,5,1,1]                       {1:6}
 TTT      Retrieve input from heap   [110,5,1,6]                       {1:6}
 TSST     Subtract (1-6)             [110,5,-5]                        {1:6}
 TSSS     Add (5+-5)                 [110,0]                           {1:6}
 NTSTN    If 0: Jump to Label DONE   [110]                             {1:6}
NSSTN    Create Label DONE           [110]                             {1:6}
 TNST     Print as integer to STDOUT []                                {1:6}      110

Stops with an error after printing the result, because no exit is defined.

@WasifHasan You can't really compare answers across different answers tbh. Whitespace simply is pretty verbose, since it has limited amount of builtins for the stack manipulation. I'm sure it can be slightly shorter somehow, but I don't think below 100 bytes is possible. To give another example: taking an input through STDIN/system-args, converting it to an integer, checking if that integer is a prime, and then outputting that boolean to STDOUT is 1 byte in 05AB1E, but 108 bytes in Java.

Thanks I just do not know Whitspace (Pls don't mind)

@WasifHasan Np, I was mainly trying to explain why some languages are longer than others. :) And you can click on the link in my header to see the Whitespace tutorial and see the limited amount of builtins available in the language.

05AB1E, 11 bytes
F2‰`s}ÎƒT*+

Fixed with help of @Grimmy.
Try it online or verify the first \$[0,25]\$ inputs.
Explanation:
F       # Loop the (implicit) input-integer amount of times:
 2‰     #  Take the divmod-2 ([n//2, n%2]) of the top value on the stack
        #  (which will be the (implicit) input-integer in the very first iteration)
   `s   #  Push them separated to the stack, and swap their order
}Î      # After the loop: push 0 and the input to the stack
  ƒ     #  Loop the input+1 amount of times:
   T*   #  Multiply the top value by 10
     +  #  And add the top two values together
        # (after which it is output implicitly as result)

J isn't an arithmetic operator, conditional statement, loop or variable. I think you need to do something like this, which as a bonus doesn't leave leading 0's.

@Grimmy Ah, you're completely right. J isn't allowed.. Thanks for the fix!

PHP, 45 44 43 bytes
for(;$a=&$argn>=1;$a/=2)$n=$a%2 .$n;echo$n;

Try it online!
As the output is a string, it supports up to PHP_INT_MAX integers
Thanks to @MariaMiller for saving 1 byte!
Thanks to @GuillermoPhillips for the reference assignment trick!

44 bytes (-1 byte)

@MariaMiller nice trick, thanks!

One for 43 bytes

@GuillermoPhillips thanks! I had thought about a way not to reset $a each loop turn but didn't think about reference.. just hope it doesn't count as an invalid operator :D

Perl 5 -Minteger -p, 32 bytes
$\+=$_%2*10**$i++,$_/=2while$_}{

Try it online!
Uses no concatenation.  If concatenation is allowed, it would get a little shorter:
26 bytes
$\=$_%2 .$\,$_/=2while$_}{

Try it online!

Ruby, 26 bytes
f=->n{n>0?n%2+10*f[n/2]:n}

Try it online!

Erlang (escript), 36 bytes
Port of various answers.
b(0)->0;b(N)->N rem 2+10*b(N div 2).

Try it online!
Erlang (escript), 37 bytes
Outputs a list of integers; it's longer by 1 byte anyway with concatenation ...
b(0)->[];b(N)->b(N div 2)++[N rem 2].

Try it online!

MathGolf, 12 bytes
Longer than 05AB1E because MathGolf doesn't have divmod ...
_{2‼%/}k{♂*+

Try it online!
Explanation
_            We have to copy the input because
             MathGolf outputs 0 over an empty stack.
 {    }      Do that input times:
   ‼%/       "Moddiv"
  2          by 2 (This saves the swapping of the stack)
       k     Repeat input times:
        {♂*  Multiply TOS by 10
           + And add second-to-top

MathGolf, 10 bytes
If only concatenation is allowed. MathGolf cleverly avoids the leading zeroes, unlike 05AB1E which doesn't.
_{2‼%/}]yx

Try it online!
Explanation
_          We have to copy the input because
           MathGolf outputs 0 over an empty stack.
 {2‼%/}    Mod-div by 2 input times over input
       ]   Wrap whole stack into a list
        y  Join the list into a number
         x Reverse the number, removing leading zeroes
           Anyway, the old 05AB1E answer used it, so I guess it's valid...

PHP, 55 bytes
for($p=2**32;$p=$p/2%$p;)echo($f+=$v=$argn/$p%2)?$v:'';

Try it online!
If concatenation is allowed, then see the other PHP answer by @Kaddath.
How
Take digits starting from most significant bit, which is leftmost. To strip leading zeroes, just accumulate the bit values until it goes above 0, then start displaying.
Doesn't work for zero! Not sure if I'm allowed to have the power (**) operator?

brainfuck, 50 bytes
>,[[->>>+<[-<+>>-]>[-<+>>]<<<<]+>>[-<<+>>]<]<[-.<]

Try it online! (with 10 as input)... Or try this naïve version with human-readable output, where I just added 48 + signs by hand, so that you guys can read the output.
How it works:
Reads the input and does the following, iteratively:

divide by 2, finding quotient and remainder
save the remainder + 1 on the left (this will make it easier to retrace the binary representation later)
move the tape right and repeat with this quotient as the new input

Then we walk left, printing the remainders, by first decreasing them by 1 to restore their real value.

Jelly, 8 bytes
HḞÐ¿ṖḂṚḞ

Try it online!
A monadic link taking an integer and returning a list of binary digits.
Explanation
 ḞÐ¿     | While the current value converted to integer (by flooring) is non-zero, do the following, collecting up intermediate values:
H        | - Halve
    Ṗ    | Remove last
     Ḃ   | Mod 2
      Ṛ  | Reverse list
       Ḟ | Convert to integer

Perl 6, 26 bytes
{[R~] ($_,*div 2...^0)X%2}

Try it online!
Uses concatenation, as well as some questionable interpretations of loops for [R~], ... and X.

Japt, 9 bytes
©u +A*ßUz

Try it

K (ngn/k), 26 bytes
1_(*:){(-2 2!\:*x),1_x}/,:

Try it online!

Pascal, 160 B
This is a complete program according to ISO standard 7185 “Standard Pascal” using your standard Horner scheme recursively.
program p(input,output);var n:integer;procedure p(n:integer);begin if n>1 then p(n div 2);write(n mod 2:1)end;begin read(n);if n<0 then write('-');p(abs(n))end.

Ungolfed:
program changeBaseDecimalToBinary(input, output);

var
    n: integer;

procedure convert(n: integer);
begin
    if n > 1 then
    begin
        convert(n div 2)
    end;
    { Print in reverse order. ----------------------------------- }

    { The `:1` specifies the _minimum_ width.
      If omitted, a processor-defined default is inserted.
      This would potentially cause ugly spaces between digits. }
    write(n mod 2:1)
end;

{ === MAIN ====================================================== }
begin
    read(n);
    { In Extended Pascal you would write `write('−':ord(n < 0))`. }
    if n < 0 then
    begin
        write('−')
    end;

    convert(abs(n))
end.

authors: Bob Jarvis - Слава Україні

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
An unknowably odd function
This challenge initially appeared in this challenge  as a an extra brain teaser.  I am posting it with permission from the original author so that we can have a formal competition.

Your task here will be to implement a function1 that forms a permutation on the positive integers.  This means that each positive integer should be the output of calling the function with exactly one positive integer.
In the earlier challenge we calculated the odd probability for such sequences.  We defined it as so:
If we have a function \$f\$ the probability of a number being odd will be defined as the limit of ratio odd members of the set to the size of the set \$f\{1\dots n\}\$ as \$n\$ tends towards infinity.
$$\lim_{n\rightarrow \infty}\dfrac{\left|\{x : x \in \{1\dots n\}, \mathrm{odd}(f(x))\}\right|}{n}$$
Your task is to write a function with no defined odd probability.  That is a function \$f\$ for which the above limit does not converge.

This is code-golf so answers will be scored in bytes with less bytes being better.

1: Here function will mean program or function.  It is just a piece of code that takes input and produces output.

Was it hard to get permission from the original author?

@LuisMendo Yes very, I wanted to post this a long time ago but it took me ages to convince them. :)

JavaScript (ES7),  33  29 bytes
This is A307485: one odd, two even, four odd, eight even, etc.
n=>n-~n-(4<<Math.log2(n))/3|0

Try it online!
For \$n\in\mathbb{N}^*\$, this is equivalent to:
$$a(n)=2n+1-\left\lceil\frac{2^{\lfloor log_2 n\rfloor+2}}{3}\right\rceil$$
It produces the sequence:
1
2 4
3 5 7 9
6 8 10 12 14 16 18 20
...

The ratio of odd values is 'bouncing' ad infinitum between \$1/3\$ and \$2/3\$, more and more slowly:

Are you sure this works? Unlike Luis' method, your blocks grow linearly.

@xnor It was wrong indeed. I've switched to another approach.

sed -E, 20 17 bytes
s/\B(.)(.*)/\2\1/

Try it online!
Saved 3 bytes as per user41805's suggestion.
This takes the input number and moves the 2nd digit (from the left) to the end of the number (the one's place).
The numbers from 1 to 10n are just rearranged, so the proportion of odd numbers for inputs up to 10n is 0.5.
All the numbers from 10n+1 to 10n+10n-1-1  map to even numbers, so the proportion of odd numbers for inputs up to 10n+10n-1 is
$$\frac{10^n/2+1}{10^n+10^{n-1}}=\frac{5+10^{-(n-1)}}{11},$$
which approaches 5/11 as n approaches infinity.

I believe \B can help save some bytes.

@user41805  Thanks -- I haven't even really looked at golfing this yet :) .

This could be 6 bytes in Retina.

@Neil  How would you do this in 6 bytes? I took a quick look at the Retina documentation (not being familiar with the language), and I posted an answer at https://codegolf.stackexchange.com/a/200959/59825  -- but the direct port from sed that I did is 17 bytes long.

@xnor already took the first step, which is that all you need to do is to reverse the digits after the first. Since Retina has a built-in that reverses the characters in the match, all you then have to do is to ensure that your match contains all characters except the first.

@Neil  Thanks -- I already knew the reversal method (my earliest version, before I even posted the sed one, was a bash script that worked that way using rev), but I didn't know Retina well enough.  If you want to post the Retina answer, please go ahead -- it would be one of the shortest answers here, but I can't post something I didn't write :) !

@MitchellSpector Thanks, I guess the amount of extreme golfing I applied to your answer means that there's not much of your answer left in which case it's fair to call it my answer at that point.

@Neil -- Yes, that's what I thought.  I'd enjoy seeing what you can do with it anyway, to help as I start to learn Retina.

@user41805 I finally got around to looking at your \B suggestion -- thank you, it saved 3 bytes.

Beautiful idea @MitchellSpector!

MATL, 18 17 16 bytes
:"vtn@W:2e+!h]G)

Try it online!
This produces the following permutation of the positive integers:
1 2 3 5 4 6 7 9 11 13 8 10 12 14 15 17 19 21 23 25 27 29 16 18 20 22 24 26 28 30 ...

The pattern is easier to see if the sequence is arranged as follows (read top to down, then left to right):
1
2
3   5
4   6
7   9 11 13
8  10 12 14
15 17 19 21 23 25 27 29
16 18 20 22 24 26 28 30
...

It's clear that the cumulative proportion of odd values has limit superior 2/3 and limit inferior 1/2. Or see the proportion graphically at MATL Online!
Explanation
The code produces a longer sequence than needed (with length exponential in the input number), and then outputs the term specified by the input.
:       % Implicit input, n. Push range [1 2 ... n]
"       % For each k in [1 2 ... n]
  v     %   Concatenate stack vertically. This is only useful in the first
        %   iteration, to produce the empty array [], which will later be
        %   extended with terms of the sequence
  tn    %   Duplicate sequence so far. Push its number of elements, say m
  @W:   %   Push range [1 2 3 ... 2^k]
  2e    %   Arrange as a two-row matrix in column-major order. Gives
        %   [1 3 5 ... 2^k-1;
        %    2 4 6 ... 2^k]
  +     %   Add, element-wise. Gives
        %   [m+1 m+3 m+5 ... m+2^k-1;
        %    m+2 m+4 m+6 ... m+2^k]
  !h    %   Transpose, then concatenate into a row vector. This extends the
        %   sequence. The transpose is needed so that, when concatenating,
        %   the terms are included in the correct order
]       % End
G)      % Take the n-th entry. Implicit display

APL (Dyalog Extended), 8 4 bytes
⌽1⌽⍞

Try it online!
Based on xnor's idea to keep the first digit and reverse the rest. A full program that takes the input from STDIN as a string, rotates left once (1⌽), reverses (⌽), and prints to STDOUT.

APL (Dyalog Extended), 8 bytes
⊥1,1⌽1↓⊤

Try it online!
Generates a sequence that is very similar to Luis Mendo's MATL answer:
1
2
3
4 6
5 7
8 10 12 14
9 11 13 15
16 18 20 22 24 26 28 30
17 19 21 23 25 27 29 31
...

How it works
⊥1,1⌽1↓⊤
       ⊤  ⍝ Convert to binary digits
     1↓   ⍝ Remove the leading 1
   1⌽     ⍝ Rotate left once; move 2nd bit to last
 1,       ⍝ Add back the leading 1
⊥         ⍝ Convert binary digits to integer

A080541

Haskell, 18 bytes
f(h:t)=h:reverse t

Try it online!
Based on Mitchell Spector's idea. Leaves the first digit in place and reverses the rest. Input and output are as strings.

Retina, 6 5 bytes
,V1,`

Try it online! Link includes test cases shamelessly stolen from @xnor. Uses the same suffix reversal algorithm inspired by @MitchellSpector's sed answer. Edit: Saved 1 byte thanks to @FryAmTheEggman. Explanation:
V`

Reverse the matched characters (defaults to matching each line).
,

Reverse all matches
1,

Exclude the first character of each match from being reversed. (^0 also works.)

You can get 5 bytes by using the stage limits instead of a regex.

Python, 22 bytes
lambda s:s[0]+s[:0:-1]

Try it online!
Based on Mitchell Spector's idea. Leaves the first digit in place and reverses the rest. Input and output are as strings.

Pure Bash, 27 bytes
echo ${1:0:1}${1:2}${1:1:1}

Try it online!
This uses the same method as my sed answer.

Retina, 18 17 bytes
(.)(.)(.*)
$1$3$2

Try it online!
This is a port of my sed answer (moving the second digit to the far right).  I've never programmed in Retina before, so I took a quick look at the language documentation and put this together.  I assume that it can be made much shorter using more advanced features of Retina.
Also, if there's any error in the Retina code, please let me know.  It does appear to work :) .

If you want to preserve your algorithm, you can still save bytes by using the reverse stage. I'm not convinced this is optimal, even without using the different approach Neil suggested. Happy Retina golfing :)

@FryAmTheEggman I really don't know Retina yet, so if you want to post the 5-byte version, please go ahead.  (I suggested that Neil post the 6-byte version, which he's done.)

I've moved my suggestion to his post, since it is just a golf of it. I hope you do get to know Retina :)

@FryAmTheEggman Thanks -- it looks like a great language, and seeing posted examples makes it easier to learn.

Charcoal, 7 bytes
§θ⁰⮌✂θ¹

Try it online! Link is to verbose version of code. This is the Charcoal port of the 6-byte Retina 1 answer that I alluded to in my comments to @MitchellSpector's sed answer, and then presumably independently discovered by @xnor. I/O as strings (which Charcoal defaults to anyway). Explanation:
§θ⁰

Print the first character of the input number.
⮌✂θ¹

Print the remaining characters of the input number, but reversed.


text:
Calculate the average longest common substring exactly
[Question inspired by Can you calculate the average Levenshtein distance exactly? . Thank you Anush. ]
The longest common substring between two strings is the longest substring which is common to both.  Please note this is not the same as the longest common subsequence whose fastest algorithm takes quadratic time.
The challenge is to compute the average length of the longest common substring between two independent and uniformly random chosen binary strings of length n each.  Your output must be exact but can be given in any easy to understand human readable form.
Examples for n = 1..12

1/2
9/8
7/4
295/128
361/128
6741/2048
15217/4096
8389/2048
291431/65536
2500643/524288
2657159/524288
22420789/4194304

Score
Your score is the highest value of  you can reach. I will run your code on my Linux machine for 1 minute and then kill the job to get the score.
I will maintain a leaderboard that shows the best score for each language used in an answer.
Worked example
Following a request, here is the full set of distances for n = 3. I have not include strings B and A if A and B are already listed. This is because the distance function is symmetric.
000 000 3
000 001 2
000 010 1
000 011 1
000 100 2
000 101 1
000 110 1
000 111 0
001 001 3
001 010 2
001 011 2
001 100 2
001 101 2
001 110 1
001 111 1
010 010 3
010 011 2
010 100 2
010 101 2
010 110 2
010 111 1
011 011 3
011 100 1
011 101 2
011 110 2
011 111 2
100 100 3
100 101 2
100 110 2
100 111 1
101 101 3
101 110 2
101 111 1
110 110 3
110 111 2
111 111 3

Leaderboard

n = 22 in C++ by my pronoun is monicareinstate.
n = 18 in Rust by Plasma_000.
n = 14 in C by Mitchel Spector.
n = 11 in Python with pypy 3 by Alex.

Do the fractions have to be reduced?

@Adám No they don't. But note this is not [tag:code-golf]

Anything preventing hard-coding the fractions?

@Adám It's a fastest-code question so surely this must be covered by a standard loop-hole. Your code should actually compute the answers it outputs. If you find a closed form formula that is of course OK to use.

Are the numbers in the example for longest common substring or subsequence?  It looks to me like they are subsequence, but the text says substring.

@Xcali Unless there is a bug, they are substrings. Could you let me know the smallest example you think is wrong?

For n=3, I'm the code I'm working with is giving 100/64 (unless I'm doing it wrong).  Also, look at the Wolfram answer which comes up with the numbers in the examples, but it's explicitly asking for subsequences, not substrings.

@Xcali If you read https://reference.wolfram.com/language/ref/LongestCommonSubsequence.html then you see that despite its name, it is working with substrings (note the word contiguous).

I see that now, but I still don't see where the example numbers are coming from (i.e. what I'm doing wrong and why I'm getting different results).  Maybe if there was a completely worked out example, especially for n=3, it would help.

@Xcali I added the distances for n = 3 to the question. I hope it helps!

Let us continue this discussion in chat.

Am I right that this takes n log n time?

@S.S.Arne It is linear time to find the longest common substring between two strings

What specific CPU do you have?  I assume x86 even though you only said "Linux" (which could be AArch64, m68k, PowerPC, ...).  Intel Haswell?  Skylake?  Or AMD Zen?  If I wanted to use x86 BMI2 bit-manipulation instructions like pext, or AVX2, would that be supported?  Skylake-X for AVX512BW?  Ice Lake for AVX512VBMI?  I assume not AVX512VP2INTERSECT for _mm_2intersect_epi32 to find any matches from each element of one vector against any of another; I don't think any CPUs have it yet :P

@PeterCordes Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz

@mypronounismonicareinstate But they were right in any case :) (We talked in a chat room.)

C++, n = 21 (40s on an AMD Ryzen 5 2500U)
This used to be a fast brute force answer that got up to n=17. That is currently preserved in the revision history.
#include <cstring>
#include <omp.h>
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>

typedef unsigned uint;
typedef unsigned char byte;
const int threadnum = 8;
const int maxn = 22; //for 24 bytes total size of Row
struct Row; struct hasher { size_t operator ()(const Row& row) const; };
struct Row
{
    char max = 0;
    std::array<char, maxn+1> row {0};
    Row() { }
    Row(int nmax)
    {
        max = nmax;
    }
    bool operator ==(const Row& rhs) const
    {
        const uint64_t* x = reinterpret_cast<const uint64_t*>(this);
        const uint64_t* y = reinterpret_cast<const uint64_t*>(&rhs);
        return x[0] == y[0] && x[1] == y[1] && x[2] == y[2];
    }
};
uint64_t rotl(uint64_t x, char a)
{
    return (x << a) | (x >> (64 - a));
}
size_t hasher::operator() (const Row& row) const
{
    const uint64_t* mem = reinterpret_cast<const uint64_t*>(&row);
    //I tried really many different hashes...
    uint64_t h = mem[0]; h += rotl(h, 4);
    h         ^= mem[1]; h += rotl(h, 4);
    h         ^= mem[2]; h += rotl(h, 4);
    return h;
}
const short hashTableSize = 1009;
struct Map
{
    std::array<std::pair<Row, int>, hashTableSize> table {};
    Map()
    {
    }
    void add_or_add(const Row row, const int delta)
    {
        size_t hash = hasher()(row) % hashTableSize;
        while(table[hash].second != 0 && !(table[hash].first == row))
        {
            hash++;
            if(hash == hashTableSize) hash = 0; //just loop :)
        }
        if(table[hash].second == 0)
            table[hash].first = row;
        table[hash].second += delta;
    }
    void clear()
    {
        std::memset(table.data(), 0, sizeof(table));
    }
};

constexpr uint bitRev(uint n)
{
    n = ((n >> 1) & 0x55555555) | ((n << 1) & 0xaaaaaaaa);
        n = ((n >> 2) & 0x33333333) | ((n << 2) & 0xcccccccc);
        n = ((n >> 4) & 0x0f0f0f0f) | ((n << 4) & 0xf0f0f0f0);
        n = ((n >> 8) & 0x00ff00ff) | ((n << 8) & 0xff00ff00);
        n = ((n >>16) & 0x0000ffff) | ((n <<16) & 0xffff0000);
        return n;
}
constexpr bool is_substring(int target, char n, short subs, char m)
{
    //n=2, m=1 -> i from 0 to 1
    int max = n-m+1;
    bool flag = false;
    for(int i = 0; i < max; i++)
        flag |= (((target >> i) ^ subs) & ((1<<m) - 1)) == 0;
    return flag;
}
int supermax = 0;
int main()
{
    uint n; std::cin >> n;
    std::vector<uint64_t> sums(threadnum);
    uint64_t sum = 0;
#pragma omp parallel for num_threads(threadnum) schedule(dynamic)
    for(uint sa = 0; sa < 1<<~-n; sa++) //the second half is the bitwise complement of the first one
    {
        uint sb = bitRev(sa);
        sb ^= -(sb >> 31);
        sb >>= 32 - n;
        if(sb < sa) continue;
        //find a lower bound = len(the shortest non-substring of sa) - 1
        //if Row.max is immediately set to it, that reduces the number of states slightly
        char lb = 0; bool found = false;
        for(char len = 0; len < 10; len++)
        {
            for(short j = 0; j < (1<<len); j++)
                if(!is_substring(sa, n, j, len))
                {
                    lb = len - 1;
                    goto out;
                }
        }
        out:;
        Map dpcur;
        Map dpnext;
        dpcur.add_or_add(Row(lb), 1);
        int ans = 0;
        for(char j = 0; j < n; j++)
        {
            for(auto[row, cnt] : dpcur.table)
            {
                if(!cnt) continue;
                Row nr0 {}, nr1 {};
                nr0.max = nr1.max = row.max;
                for(char i = 0; i < n; i++)
                {
                    Row& r = (sa >> i)&1 ? nr0 : nr1;
                    r.row[i+1] = row.row[i] + 1;
                }
                char n0max = 0, n1max = 0;
                for(char i = 0; i < 23; i++)
                    n0max = std::max(n0max, nr0.row[i]);
                for(char i = 0; i < 23; i++)
                    n1max = std::max(n1max, nr1.row[i]);
                //possibly, cut an entire would-be branch that would never improve!
                if(n0max + n - j - 1 <= nr0.max)
                    ans += (cnt * nr0.max) << (n - j - 1);
                else
                    nr0.max = std::max(nr0.max, n0max), dpnext.add_or_add(nr0, cnt);
                if(n1max + n - j - 1 <= nr1.max)
                    ans += (cnt * nr1.max) << (n - j - 1);
                else
                    nr1.max = std::max(nr1.max, n1max), dpnext.add_or_add(nr1, cnt);
            }
            std::memcpy(dpcur.table.data(), dpnext.table.data(), sizeof(Map));
            dpnext.clear();
        }
        for(auto[row, cnt] : dpcur.table)
            ans += cnt * row.max;
        sums[omp_get_thread_num()] += ans;
        if(sb != sa)
            sums[omp_get_thread_num()] += ans;
    }
    for(uint64_t e : sums) sum += e;
    sum *= 2;
    printf("%ld\n", sum);
    uint64_t num = sum, denom = 1ll<<(2*n);
    while(num % 2 == 0) num /= 2, denom /= 2;
    printf("%ld/%ld\n", num, denom);
}

This uses OpenMP for multi-threading. To be compiled with clang++ -std=c++17 -Ofast -march=native -flto -fopenmp file.cpp.
Explanation I tried (please don't use it as a Rust translation guide)
The longest common substring can be found in \$O(n^2)\$ time via dynamic programming. That dynamic programming can be calculated (if the strings are \$s\$ and \$t\$) via the formula $$dp_{i,j} = \begin{cases}dp_{i-1,j-1} + 1& s_i = t_j\\0& \text{otherwise}\end{cases}$$
(and then the answer is just the highest value in \$dp\$). A naive solution would be to iterate over pairs of strings of length \$n\$ (resulting in \$O(4^n n^2)\$ time complexity). However, instead of simply doing that, my program only iterates over all possible values of the first string. Then, it simply does that, but instead of storing a proper dynamic programming array (that wouldn't be possible because there is no second string), it stores an array of all possible rows in it with counters of how many ways exist to reach this row. To calculate the next array of possible rows from the current array of possible rows, my program simply tries all of them with both possible values of the next bit in the second string. This leads to a speedup, because if two prefixes of the second string lead to the same state, they can be "merged" into one execution path.
I suspect this is similar to the optimization from the top answer in a similar challenge but for Levenshtein distance, but the explanation there is so bad I couldn't understand it at all.
The optimization that got this to 21: if at a certain point a possible row is encountered such that all its numbers are too small to ever improve the length of the longest substring in it, it can be directly calculated how much it will add to the answer.
Takes input as a single number from stdin. Outputs 734551/131072 for 13, 392340511/67108864 for 14, 1630366263/268435456 for 15, 6751032665/1073741824 for 16, 6967595579/1073741824 for 17, 114759115773/17179869184 for 18, 235733542633/34359738368 for 19, 1933121200141/27877906944 for 20 and 7912473298597/1099511627776 for 21.

Ah, very nice! Smart to use a bitmask and bitwise shifts to check for common binary substrings! No need to convert to a binary-string at all in that case, since you're working on the integer-bits. Looks so obvious now that I see it, but you'd still have to come up with an approach like that.

Thanks for this. Do you think this can be made multi-threaded? I will be very interested if an n log n or even linear time longest common subsequence algorithm can beat this in the end.

@fomin I was actually working on multi-threading while you were writing the comment. I have not tried (or even properly read about) better longest common substring algorithms yet.

I like your speedup a lot! Out of interest, is it as fast as the fastest Levenshtein solution?  You might have thought this problem should be easier than the Levenshtein one given that the longest common substring problem has a linear time solution, but maybe not.

@Anush Currently that Levenshtein Rust answer seems to behave approximately like mine (given the performance difference between our CPUs).

Another great speed up! Very impressive.

You can bit-reverse faster on x86 with SSSE3 pshufb (_mm_shuffle_epi8) as a lookup table for nibbles.  e.g. Efficient Algorithm for Bit Reversal (from MSB->LSB to LSB->MSB) in C has an AVX2 version.  mirror bits of a 32 bit word.  That should be faster even for a single integer than your bitRev().  Unfortunately even x86 BMI2 didn't add an equivalent of ARM's rbit instruction that bit-reverses a register extremely cheaply.

@PeterCordes I knew there are better ways to reverse bits, but in this case it does exactly 2^(n-1) or something similar bit reversals, so it is not a bottleneck at all. I have improved the code slightly since the last edit, including rewriting the innermost loop to use SIMD, but I have also increased maxn to 30, so the gains are small.

I was looking at your old brute-force version.  Bitwise xor shifted inputs and find the longest contiguous sequence of zero bits, I guess.  I was thinking shift and clz or ctz.  (Oh, you use a LUT; makes sense).  But anyway _bzhi_u32 should be fast on Ryzen.  https://www.uops.info/table.html says it's 1 uop with 1c latency and 3/clock throughput on Zen+ (which is just a die-shrink of original Zen, same per-clock performance).  Same on Intel, except "only" 2/clock throughput.  But possibly GCC does a poor job of optimizing it for some reason, and does better with other surrounding code.

I remember trying _bzhi_u32. It has not sped things up (or did it even slow them down for some reason?). I doubt that that version can be sped up to match the current one, anyway.

Wolfram Language (Mathematica), n=12 (~53s TIO)
t=0;
For[i=0,i<2^a,i++,
   For[j=0,j<2^(a-1),j++,
    t=t+Length@LongestCommonSubsequence[IntegerDigits[i,2,a],IntegerDigits[j,2,a]]]]

Try it online!

Is this longest common substring? It looks like you are computing longest common subsequence which is not the same thing.

@Anush Did you try it on line? It produces the exact correct results! do you just downvote based on watching the code?

Hmm..I am happy to change the vote but you have to edit the question to let me do that.  Why is it called subsequence if it is really computing substrings?

@Anush the best way to test an algorithm is to tio and to see if it answers the question. If you want to find details on a specific command try the Wolfram Language online documentation...

Python 3 308 293 bytes, n=10 (30sec TIO)
a=lambda S,T:max((*(i+1 for i in range(len(S)) for j in range(len(S)-i)if S[j:j+i+1]in T),0));b=lambda i,n:'0'*(n-len(bin(i)[2:]))+bin(i)[2:]
for n in range(1,11):m=2**n;t=sum([a(b(i,n),b(j,n))for i in range(m)for j in range(m)]);y=bin(t);v=2**(len(y)-len(y.rstrip('0')));print(t/v,'/',4**n/v)

Try it online!
Not elegant or super fast but it's the first time I've been able to get something like this on so few lines. Potential speed up possible with numpy functions.
I feel like this problem is similar to Project Euler Question 701. Maybe with an algorithm for that this problem could be done in sub-exponential time.

This is not code golf so no need to worry about bytes.

Slight performance improvement with b=lambda i,n:bin((2<<n)+i)[4:].

Rust, (n=15 ~6 sec, n=16 ~25 sec on 2.5GHz intel i7)
More heavily parallelised rewrite of @monicareinstate's answer in rust

src/main.rs

use rayon::prelude::*;

const MAX_N: usize = 22;

const ARRAY_SIZE: usize = 1 << MAX_N;

static mut LOOKUP: [u8; ARRAY_SIZE] = [0; ARRAY_SIZE];

#[inline]
fn longest_sub(left: u32, right: u32, bits: u8) -> (u8, u8) {
    // Uses of unsafe are sound here since we are only reading immutably
    let mask = (1u32 << bits) - 1;
    let unshifted = mask & !(left ^ right);
    let max_unshifted = unsafe { *LOOKUP.get_unchecked(unshifted as usize) };
    let max_shifted = (1..bits)
        .map(|shift| {
            let mask = (1u32 << (bits - shift)) - 1;
            let shift_l = mask & !((left >> shift) ^ right);
            let shift_r = mask & !(left ^ (right >> shift));
            unsafe {
                std::cmp::max(
                    *LOOKUP.get_unchecked(shift_l as usize),
                    *LOOKUP.get_unchecked(shift_r as usize),
                )
            }
        })
        .max()
        .unwrap();

    let max = std::cmp::max(max_unshifted, max_shifted);
    if left == right {
        (max, 1)
    }
    else {
        (2 * max, 2)
    }
}

#[inline]
fn calculate(bits: u8) -> (u64, u64) {
    for number in 1..1usize << bits {
        // Safe since we have no other references to LOOKUP in the current program
        unsafe {
            *LOOKUP.get_unchecked_mut(number) = 1 + LOOKUP.get_unchecked(number & (number >> 1))
        }
    }

    (0..1u32 << bits)
        .into_par_iter()
        .flat_map(move |left| {
            (left..1u32 << bits)
                .into_par_iter()
                .map(move |right| longest_sub(left, right, bits))
        })
        .map(|(max, weight)| (max as u64, weight as u64))
        .reduce(|| (0, 0), |a, b| (a.0 + b.0, a.1 + b.1))
}

fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    let line = line.trim();
    let number = line.parse().unwrap();

    let (num, denom) = calculate(number);
    let (num, denom) = {
        let (mut a, mut b) = (num, denom);
        while a % 2 == 0 && b % 2 == 0 {
            a /= 2;
            b /= 2;
        }
        (a, b)
    };
    println!("{}/{}", num, denom);
}

Cargo.toml

[package]
name = "golf"
version = "0.1.0"
authors = ["Plasma_000"]
edition = "2018"

[profile.release]
opt-level = 3
lto = true

[dependencies]
rayon = "1.3"

Build with

RUSTFLAGS="-Ctarget-cpu=native" cargo +nightly build --release

Using nightly compiler 1.43.0
This performs a very slightly faster than the @monicareinstate's current answer on my machine:
❯ time "echo 15 | ./target/release/golf"
Benchmark #1: echo 15 | ./target/release/golf
  Time (mean ± σ):      5.872 s ±  0.114 s    [User: 21.332 s, System: 0.127 s]
  Range (min … max):    5.665 s …  6.017 s    10 runs

VS @monicareinstate's
❯ time "echo 15 | ./a.out"
Benchmark #1: echo 15 | ./a.out
  Time (mean ± σ):      5.983 s ±  0.092 s    [User: 22.038 s, System: 0.120 s]
  Range (min … max):    5.868 s …  6.157 s    10 runs

EDIT: well done @monicareinstate on your latest edit, you have me beat :)

no targets specified in the manifest
either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present

@anush Did you fail to name the file src/main.rs? If it’s named main you shouldn’t have to add [[bin]] to the manifest

Thanks. You have reached n = 18.

Java, n=11 (~30-35 sec on TIO)
import java.util.ArrayList;
import java.util.List;
class Main{
  public static void main(String[] args){
    for(int n=1; ; n++){
      String binaryFormat="%"+n+"s";
      int sum=0, c=0;
      double powerOf2=Math.pow(2,n);
      for(int a=0; a<powerOf2; a++){
        String binaryA=toBinary(n,a);
        for(int b=0; b<powerOf2/2; b++){
          String binaryB=toBinary(n,b);
          sum += solve(binaryA, binaryB);
          c++;
        }
      }
      System.out.println(n+": "+sum+"/"+c);
    }
  }

  private static String toBinary(int n, int a){
    return String.format("%"+n+"s", Integer.toBinaryString(a)).replace(' ','0');
  }

  private static int solve(String a,String b){
    String s=a+2+b+3;
    List<Integer> M = new ArrayList<>();
    for(int c : s.getBytes())
      M.add(c);
    List<Integer> S = suffixList(M, 51);
    List<Integer> I = new ArrayList(S);
    for(int i=0; i<S.size(); i++)
      I.set(S.get(i), i);
    int L=0,R=0,m=0,h=0;
    for(int i=0; i<S.size(); i++){
      if(I.get(i)!=0){
        int j=S.get(I.get(i)-1);
        while(s.charAt(i+h)==s.charAt(j+h))
          h++;
        if(h>m){
          int len = a.length();
          int sortedMid = (i-j)*(j-len)>0 ? j
                                          : (i-j)*(i-len)>0 ? len
                                                            : i;
          if(len == sortedMid){
            m=h;
            L=i<j?i:j;
            R=L+h;
          }
        }
        if(h>0)
          h--;
      }
    }
    return R-L;
  }

  private static List<Integer> suffixList(List<Integer> s, int K){
    int n=s.size();
    s.add(0);s.add(0);s.add(0);
    int n0=(n+2)/3, n1=(n+1)/3, n2=n/3;
    int n02=n0+n2;
    int adj=n0-n1;
    int length=(n+adj)/3;
    List<Integer> A=new ArrayList<>();
    for(int x=0; x<n+adj; x++)
      if(x%3!=0)
        A.add(x);
    A.add(0);A.add(0);A.add(0);
    radixPass(K,s,A,2,n02);
    radixPass(K,s,A,1,n02);
    radixPass(K,s,A,0,n02);
    List<Integer> B=new ArrayList<>();
    for(int i=0; i<n02; i++)
      B.add(0);
    int[] t=new int[3];
    int m=0;
    for(int i=0; i<n02; i++){
      int x=A.get(i);
      int[] u=new int[3];
      for(int j=x; j<x+3; j++)
        u[j-x]=s.get(j);
      if(t[0]!=u[0]||t[1]!=u[1]||t[2]!=u[2])
        m++;
      t=u;
      B.set(x/3+x%3/2*n0, m);
    }
    if(n02==1)
      for(int i=0; i<n02; i++)
        A.set(i, 0);
    else{
      List<Integer> X = suffixList(B,m);
      for(int i=0; i<n02; i++)
        A.set(i, X.get(i));
    }
    List<Integer> I = new ArrayList<>(A);
    for(int i=0; i<n02; i++)
      I.set(A.get(i), i+1);
    B = new ArrayList<>();
    for(int x:A)
      if(x<n0)
        B.add(3*x);
    radixPass(K,s,B,0,n0);
    List<Integer> R = new ArrayList<>();
    int p=0;
    for(int T=adj; T<n02; ){
      int x = A.get(T);
      boolean bool = x>=n0;
      int b = bool?1:0;
      int i=(x-b*n0)*3-~b;
      int j=B.get(p);
      if(p==n0
         || (bool ? s.get(i)<s.get(j) || (s.get(i)==s.get(j)&&s.get(i+1)<s.get(j+1)) || (s.get(i)==s.get(j)&&s.get(i+1)==s.get(j+1)&&I.get(A.get(T)-n0+1)<I.get(j/3+n0))
                  : s.get(i)<s.get(j) || (s.get(i)==s.get(j)&&I.get(A.get(T)+n0)<I.get(j/3)))){
        R.add(i);
        T++;
      }else{
        R.add(j);
        p++;
      }
    }
    for(int i=p; i<n0; i++)
      R.add(B.get(i));
    return R;
  }

  private static void radixPass(int K, List<Integer> s, List<Integer> a, int o, int n){
    int[] c=new int[K+3];
    for(int i=0; i<n; i++)
      c[s.get(a.get(i)+o)+1]++;
    for(int i=0; i<K+3; i++)
      c[i]+=c[i<1?c.length-1:i-1];
    List<Integer> A = new ArrayList<>(a);
    for(int i=0; i<n; i++){
      int x=A.get(i);
      int j=s.get(x+o);
      a.set(c[j], x);
      c[j]++;
    }
  }
}

NOTE: The fractions aren't normalized like in the challenge description. The decimal values the fractions represent are correct, though.
Try it online with indefinite printing - times out after 60 sec or try it online with given argument \$n\$.
Only just got it working, so will try to improve its performance later on.
Short explanation of my solution:
I first modified @MitchSchwartz' Python 2 answer for the Longest common substring in linear time challenge so it will loop over the binary-string pairs we want to check. This challenge asks for the starting and ending index of the longest common substring between two strings, in lineair time (\$O(n)\$ complexity).
His answer implements 'The Skew Algorithm' described in Juha Kärkkäinen's & Peter Sanders' Simple Linear Work Suffix Array Construction article, with the implementation of the Longest Common Prefix part using the algorithm described in Toru Kasai's, Gunho Lee's, Hiroki Arimura's, Setsuo Arikawa's, and Kunsoo Park's Linear-Time Longest-Common-Prefix Computation in Suffix Arrays and Its Applications article.
Since we basically want to check all binary-string pairs \$A\$ and \$B\$, where \$A\$ are binary strings for integers \$a\$ in the range \$a=[0, 2^n)\$ and \$B\$ are binary strings for integers \$b\$ in the range \$b=[0,\frac{2^n}{2})\$ (similar as the existing Mathematica answer does), I've modified @MitchSchwartz' ungolfed answer to take the difference between the found indices, and sum those together for our numerator (the denominator will be \$n^{2n-1}\$ for any given \$n\$).
Here is that modified Python code:
Try it online printing indefinitely or try it online with given input \$n\$ (which produces \$n=9\$ in about 25-30 sec on TIO).
Since I'm not too skilled with Python, I decided to port everything to Java which I use on a daily basis. This allows me to make performance enhancing modifications (which I will try to do later on) easier. And I also knew that the larger \$n\$ would become, the better the performance of the Java program in comparison to the Python program would be (which can also be seen by checking some \$n\$ in both programs on TIO - i.e. the inputs \$n=1,5,7,9\$ will take approximately 1.5, 2.25, 1.75, 4.0 seconds in Java, but 0.02, 0.1, 1.5, 30.0 seconds in Python 2 respectively.
Long explanation:
TODO: I will describe the actual implementation and perhaps add some comments to the code later on. This already took long enough to modify and port to Java for now.

This looks great but any idea why it isn't much faster than the naive python solution of @Alec? I feel it ought to be much faster.

@Anush Ignore my now deleted comment, I actually was checking correctly.. It's too damn late on a Friday evening.. >.> So not sure why the performance of his answer is better than the Python implementation I have. If you see any potential bottlenecks in the implementation, let me know, since I'd love to improve the performance in my Java port as well then.

You could probably get some extra performance out of a solution that does bitwise operations directly on the int instead of converting it to a String representation of the binary.

@mypetlion Yeah, I've seen the C++ answer. I might port it later on to see what the performance in Java is. But for now I'm enjoying the weekend, since I've already been working on both work and this thing above for a bit too long. xD

C (gcc), 1769 bytes, n=14 in 31 sec. on TIO
n=15 in 2 min 7sec on my MacBook Pro (3.1 GHz Intel Core i7)
NOTE: If you test this program to see how far it can get in one minute,
 change #define END to be some larger number, say (17).  The value
 of (14) was picked so as not to time out in 1 minute on TIO.
Output will be computed from n = START to n = END.
Do not change the #define CUTOFF value -- this is the point at which long longs are needed, instead of just longs.
#include <stdlib.h>
#include <stdio.h>

#define START (1)
#define END (14)

#define CUTOFF (15)

// Find length of longest common substring of binary numbers a and b, of length l.
int f(int a, int b, int l)
  {
   int i, j;

   for (int lengthOfMatch=1, mask=1; lengthOfMatch<=l; lengthOfMatch++, mask = 2*mask+1)
      {
       for (i=0; i <= l-lengthOfMatch; i++)
          {
           for (j=0; j <= l-lengthOfMatch; j++)
                {
                   if ( ((a>>i)& mask) == ((b>>j) & mask) )
                     {
                      if (lengthOfMatch == l)
                        return lengthOfMatch;

                      goto NextMatchLength;
                     }
                } // for j
          } // for i

       return lengthOfMatch - 1;

NextMatchLength:
       ;
      } // for lengthOfMatch

 return 0;
} // f

int main(void)
{
 for (int numberOfBits=START; numberOfBits <= END; numberOfBits++)
  {
   if (numberOfBits >= CUTOFF)
     {
      long long t=0;

      for (int a=0;a<(1<<numberOfBits);a++)
         {
          for (int b=0; b<a; b++)
              t += f(a, b, numberOfBits);
         } // for a

// Make up for the entries f(a, a, numberOfBits) that weren't counted above.
      t += numberOfBits*(1<<(numberOfBits-1));

      printf("%d => %lld/%lld\n", numberOfBits, t, 1ll<<(2*numberOfBits-1));
     }
    else
     {
      long t=0;

      for (int a=0;a<(1<<numberOfBits);a++)
         {
          for (int b=0; b<a; b++)
              t += f(a, b, numberOfBits);
         } // for a

// Make up for the entries f(a, a, numberOfBits) that weren't counted yet.
      t += numberOfBits*(1<<(numberOfBits-1));

      printf("%d => %ld/%ld\n", numberOfBits, t, 1l<<(2*numberOfBits-1));
     }
   }

exit(0);
} // main

Try it online!

Sample output for \$n=15\$ from my MacBook Pro (3.1 GHz Intel Core i7) -- 2 min 7 sec.
$ time ./l5
1 => 1/2
2 => 9/8
3 => 56/32
4 => 295/128
5 => 1444/512
6 => 6741/2048
7 => 30434/8192
8 => 134224/32768
9 => 582862/131072
10 => 2500643/524288
11 => 10628636/2097152
12 => 44841578/8388608
13 => 188045056/33554432
14 => 784681022/134217728
15 => 3260732526/536870912

real    2m6.814s
user    2m5.842s
sys 0m0.402s