sed in unary, 16 bytes
s/^/1\n1/p;h;G;D
Try it online!
Each unary natural is on its own line. Seems to increase logarithmically.
sed has two spaces: the default one is called the pattern space and is lost after processing the next of input; the other one is the hold space, which instead is retained throughout execution. Both start empty.
(sed cannot run without input, so this program is run with an empty line as input).
The idea is to have the largest number encountered so far on the first line, and then have the result of the previous iterations on the succeeding lines.
s/^/1\n1/
replaces the beginning (symbolised with ^
, really just empty space) with 1
followed by a newline (\n
) and another 1
. The p
flag then prints the pattern space. The second 1
inserted increases the maximum number by 1, which was on the first line before the substitution, and now is on the second line.
h
replaces the hold space with the contents of the pattern space, after which G
appends the hold space to the pattern space, joining them by a newline. This is our method to retain the previous natural numbers encountered.
D
deletes the first line (which in our case is always 1
thanks to the substitution made with the s
command) and the newline after it. This effectively returns the largest number encountered so far back to the first line. Then D
causes the program to be run from the beginning with what remains of the pattern space because the first line was not empty. Because the s
command will always make sure the first line is not empty, the initial 1\n
effectively acts only for D
to cause the program to loop indefinitely.
:;s/^/1/p;h;G;t
Try it online!
sed 4.2.2 allows empty labels, ridding the need for 1\n
and D
.
realmin
) \$\endgroup\$