g | x | w | all
Bytes Lang Time Link
003Vyxal 3250425T075910ZThemooni
030Swift 6250425T012245ZmacOSist
020TIBASIC TI83 Plus250424T170546Zmadeforl
024AWK250313T203938Zxrs
055SAKO250327T162115ZAcrimori
003Regenerate a250127T175246ZUnrelate
005cQuents250128T041305ZStephen
010Retina 0.8.2201130T224637ZNeil
006Japt250126T220400ZShaggy
024CASIO BASIC CASIO fx9750GIII250126T214828Zmadeforl
019Bash201203T204154ZAdam Kat
nan230219T163151ZThe Thon
003Vyxal230219T165556ZThe Thon
007Pyt230202T015344ZKip the
016Appleseed220726T033125ZDLosc
076Python220725T235100ZEric Xue
005Vyxal220724T231403Zaketon
014Regenerate a220703T020331ZDeadcode
050Rust210302T164310ZAiden4
020PowerShell210302T090434Zwasif
127Batch210302T083726Zwasif
051Chapel210123T224706Zsech1p
070Scratch 3.0201130T210335Zlyxal
016sed in unary210123T100409Zuser4180
076Java OpenJDK 8210123T102735Zuser1004
036Python 3210123T054037ZBerken T
1715convey201214T192032Zxash
033AWK201224T214609ZPedro Ma
034Arm Thumb with libc calls201224T163030ZEasyasPi
025Wolfram Language Mathematica201130T182053ZZaMoC
020Perl 5201130T195126ZXcali
014PowerShell Core201224T020006ZJulian
027convey201217T232141ZWheat Wi
056Common Lisp201217T223443ZByte
047Nim201215T074146Zxigoi
019Zsh201201T114000Zroblogic
046Julia201202T162443ZAmir rez
024jq201203T220753ZEsolangi
054Java JDK201203T010454Zbranboye
043Rust + rand crate201201T090915ZPatiga
006Burlesque201202T165335ZMintable
061Java JDK201130T201335ZDMiddend
036AutoHotkey201201T222731ZEngineer
027Julia201202T150226ZMarcMush
005Befunge201202T031823ZPizgenal
018Raku201202T000722ZSean
017Haskell201130T233851Zxnor
021R201201T083655ZDominic
021R201130T230646ZGiuseppe
046Icon201201T080144ZGalen Iv
024R201130T185911ZRobin Ry
004Pyth201201T045745ZMukundan
031Wolfram Language Mathematica201201T081835ZGreg Mar
031Python 2201201T072608Zxnor
044C gcc201130T182644ZNoodle9
040JavaScript Browser201201T062906Ztsh
026JavaScript V8201201T054222ZNina Lis
020Bash201201T045110ZMukundan
032Factor201201T022610ZBubbler
029JavaScript V8201201T022518ZSisyphus
034JavaScript V8201130T180031ZArnauld
005Stax201201T020001ZRazetime
030PHP201201T014553ZSisyphus
043C gcc201201T010407ZSisyphus
008Charcoal201130T230022ZNeil
017Ruby201201T005917ZSisyphus
054Rust201201T002917ZEdgar Lu
011APL Dyalog Unicode201130T181839Zuser
034AWK201130T213830ZNoodle9
028Octave201130T192803ZLuis Men
013J201130T200000ZJonah
033Python 2201130T180851ZNoodle9
004Brachylog201130T184047ZUnrelate
004Jelly201130T175827Zcaird co
020sed 4.2.2201130T182907ZDigital
020Bash + GNU Coreutils201130T181844ZDigital
002Husk201130T181831Zcaird co
00205AB1E201130T181406Zovs
023Scala201130T180111Zuser

Vyxal 3, 3 bytes

kNP

Vyxal It Online!

kNP­⁡​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁣‏‏​⁡⁠⁡‌­
kN   # ‎⁡infinite list of all natural numbers
  P  # ‎⁢prefixes
💎

Created with the help of Luminespire.

<script type="vyxal3">
kNP100⊖
##note 100⊖ is support code to only output first 100, otherwise it will never stop executing
##and the snippet really doesn't like it
</script>
<script>
    args=[]
</script>
<script src="https://themoonisacheese.github.io/snippeterpreter/snippet.js" type="module"/>

Swift 6, 30 bytes

(1...).map{print([_](1...$0))}

Try it with SwiftFiddle!

TI-BASIC (TI-83 Plus), 20 bytes

both of these require the program to be named "B"

For(B,1,A
Disp B
End
A+1→A
prgmB

TI-BASIC (TI-83 Plus), 18 bytes

you can't see beyond 7 items with this but trust me its doing it

Disp seq(K,K,1,A
A+1→A
prgmB

recursiveness!!!!

AWK, 25 24 bytes

{for(;;)print s=s" "++i}

Attempt This Online!

Beats the previous AWK efforts by using string concat.

SAKO, 55 bytes

**)DRUKUJ(9,0):I
POWTORZ:I=1(1)J
POWTORZ:J=1(1)0
KONIEC

Just uses two simple nested loops.
For numbers longer than 10 characters prints in E notation. Pluses serve as delimiters.

Regenerate -a, 4 3 bytes

*1+

Attempt This Online!

-1 with the leading quantifier trick I learned from an older answer I saw a couple days ago--can't remember whether it was by DLosc, Deadcode, or someone else

Unary output. Leverages the built-in shared repetition limit as an ever-increasing \$n\ge0\$ by which to index into the antidiagonals of an infinite matrix where every row is \$\mathbb{N}\$--the leading * and the trailing + must always repeat their operands a sum of \$n+1\$ times in any given generation, where the \$+1\$ is because + is implemented such that its guaranteed first repetition doesn't count against the repetition limit.

Regenerate -a, 8 7 bytes

( +)+#1

Attempt This Online!

Decimal, and uses the repetition limit in a somewhat more complicated way with nested quantifiers, computing every ordered integer partition of \$n+1\$ and outputting only the last element of each. At repetition limit \$n\$, every generated line contains exactly \$n+1\$ spaces, but on each generation #1 only counts the number of spaces in the last iteration of the capture group. (It doesn't actually have to do this, granted, but this is how I wrote it first and it is pretty fun.)

A unary solution which leverages partitions, if not in quite the same way, is [1 ]+ for 5 bytes.


See the edit history for a variety of older explanations which may be of interest.

cQuents, 5 bytes

b$
&$

Try it online!

Outputs in the format [1],[1, 2],[1, 2, 3],[1, 2, 3, 4], ...

Explanation

b$  first line
    implicit `:` mode sequence, output terms infinitely
    each term equals
b                    second line (               )
 $                                 current index

&$  second line
&   mode sequence 2, given n output the first n terms in the sequence
    each term equals
 $                   current index

Retina 0.8.2, 11 10 bytes


_
}*!&`_+

Try it online! Outputs in unary. Explanation: The first two lines cause the number of _s to increase on each pass, while the !&`_+ generates all suffixes, which ensures that all integers get printed. The } causes the entire script to repeat indefinitely. The * causes the suffixes to be printed and discarded, since otherwise Retina does not output until the program terminates.

18 bytes for a traditional decimal output. Each integer is printed in turn, and then for each integer all of the previous integers are printed again, so the final sequence is 1, 2, 1, 3, 2, 1, 4, 3 ...

{`^
_
*(M!&`_+
%`_

Try it online!

Japt, 6 bytes

ßOp°Võ

Test it here

CASIO BASIC (CASIO fx-9750GIII), 24 bytes

1
Lbl A
For 1→X To Ans
X◢
Next
Ans+1
Goto A

you need to press enter after every number due to how CASIO BASIC works

Bash, 21 19 bytes

s()(seq $[++n];s);s
1
1
2
1
2
3
…

Run the 19B version on Try It Online

This defines a function s that runs seq NUMBER where NUMBER starts at 1 and increments with each run, then it runs itself recursively. After the definition, we run s.

For the cost of 5B to specify -s\ (separator is a space character), it can be adapted to a one answer per line solution at 24 bytes:

s()(seq -s\  $[++n];s);s
1
1 2
1 2 3
…

Run the 24B version on Try It Online

Thunno, \$ 9 \log_{256}(96) \approx \$ 7.41 bytes

[1+DR1+ZK

Attempt This Online!

13 chars for a better format: Attempt This Online!

Explanation

[1+DR1+ZK  # TOS is initially 0
[          # while True:
 1+        #  increment TOS
   DR1+    #  push range(1, TOS+1)
       ZK  #  pop and print

Vyxal, 3 bytes

Þ∞K

Try it Online!

Þ∞ɾ

Try it Online!

Explanation

Þ∞  # Push an infinite list of positive integers:   [1, 2, 3, 4, 5, ...]
  K # Get the prefixes of this list                 [[1], [1, 2], [1, 2, 3], ...]
  ɾ # Inclusive one-range of each:                  [[1], [1, 2], [1, 2, 3], ...]

Pyt, 7 bytes

1`⁺řĐƥł

Try it online!

Port of caird coinheringaahing's Jelly answer.

Appleseed, 16 bytes

(q(_(map 1to(1to

Anonymous function that can be called with no arguments and returns an infinite nested list ((1) (1 2) (1 2 3) ...). Try it online!

Explanation

(q           ; Anonymous function
 (_          ; that takes any number of arguments:
  (map 1to   ; Inclusive range from 1 to N for each N in
   (1to))))  ; numbers from 1 to infinity

Python, 76 bytes

def n():
 c=2
 while 1:
  yield from range(1,c)
  c+=1
for i in n():print(i)

Uses generators and yield from to chain infinite ranges. You can call n directly for a generator.

Vyxal, 5 bytes

{nɾṄ,

Try it Online! The 5 flag makes the online interpreter time out after 5 seconds.

Explanation:

{      # Open a(n infinite) while loop
 n     # Get the loop variable's value
  ɾ    # Push the range from 1 to n
   Ṅ   # Join by spaces (ɾ creates a list)
    ,  # Print

Regenerate -a, 14 bytes

(${$1+1} !1 )+

Attempt This Online!

The only choice for the regex to make here is how many times to repeat the (...)+ loop. The first iteration will always print 1 , because the first alternative can't match, as $1 hasn't been defined yet.

On subsequent iterations, ${$1+1} does math on $1, treating its contents as a number. It ignores the trailing space, and adds 1 to it. This then becomes the new value for $1, etc.

The ! short-circuiting alternation prevents the second alternative, i.e. 1 , from being taken once it becomes possible for the first alternative, ${$1+1} , to match.

Rust, 50 bytes

||for i in(1..).flat_map(|n|1..n){print!("{} ",i)}

Try it online!

I know there are a couple of rust answers already, but this one is deterministic and takes a different (and shorter) approach to the problem. explanation:

||for i in(1..).flat_map(|n|1..n){print!("{} ",i)} //anonymous function
          (1..)                                    //for evey n from 1..infinite
               .flat_map(|n|1..n)                  //map to range from 1..n and flatten
  for i in                       {print!("{} ",i)} //print with a trailing space

PowerShell, 20 bytes

for(){' '+(1..++$i)}

Try it online!

Batch, 127 bytes

@echo off
setlocal enabledelayedexpansion
set "s=1"
set k=1
for /L %%a in (0,0,0) do (echo !s! &set /a k=k+1 &set "s=!s! !k!") 

Chapel, 51 bytes

var i=1;while(i){for j in 1..i do writeln(j);i+=1;}

Try it online!

Scratch 3.0, 13 20 blocks/121 70 bytes

enter image description here

As SB Syntax:

define(n)(i
say(i
((n)+<(i)=(n)>)((1)+((i)*<(i)<(n

This says each term in the sequence. A delay can be added so that the numbers don't rapidly fire.

I have never seen scratch so abused. You call the empty name function with empty parameters. My goodness. Whatever saves bytes!

-51 thanks to @att

Try it on Scratch

Explained

The main idea behind this program is that each "run" of natural numbers is printed until the value being printed is equal to the highest number of that run.

The first two lines of the function are pretty straightforward...define a function with parameters n (the upper limit of the current run of numbers) and i (the current number for printing), then output the value of i.

Then, we get to the fun part - the function call. The expression n + (i = n) determines if we need to move onto the next n: if i hasn't reached the upper limit, the expression evaluates as n. Otherwise, the expression is n + 1, giving us the next upper limit.

The expression 1 + (i * (i < n)) determines the next value of i. To properly understand this, consider the two different results i < n can evaluate to: if i is equal to n (that is, we have reached the upper limit of the current run and we need to consequently restart at 1), this will result in (1 + (i * 0)), which will always equal 1. However, if i is less than n, the expression will equal (1 + (i * 1)) = (1 + i) , which just happens to be the next value to print. Because there is no checks to see if execution should be halted, this goes on forever.

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.


sed 4.2.2, 15 bytes

:;s/^/1/p;h;G;t

Try it online!

sed 4.2.2 allows empty labels, ridding the need for 1\n and D.

Java (OpenJDK 8), 76 chars

void f(){for(int i=0,j;++i>0;out.println())for(j=0;j++<i;out.print(j+" "));}

Try it online!

Output (unlimited):

1 
1 2 
1 2 3 
1 2 3 4 
1 2 3 4 5 
1 2 3 4 5 6 
1 2 3 4 5 6 7 
1 2 3 4 5 6 7 8 
1 2 3 4 5 6 7 8 9 
. . .

Python 3, 36 bytes (including newline)

s=[1]
while 1:print(s);s+=[s[-1]+1]

Try it online!

convey, 17 15 bytes

-2 thanks to Jo King!

>1\/v
:+<.+}
11

Try it online!

Previous version that used a 0-stream and incremented its indices by 1. Jo's variation uses a 1-stream that adds itself to its indices, thus shortening the last row.

left part

Starting with the top left 0, we push it to the left. \ will push its length 1 downward, it will get incremented +1 and then length + 1 new 0s will be let through. So we generate 0, 0 0, 0 0 0, …

first 30 steps

Those list get then dumped in a sink ] while their indices \. get incremented +1 and written to the output }: 1, 1 2, 1 2 3, …

AWK, 33 bytes

An approach different from @Noodle9's, that luckly uses one less byte.

{for(;;a[++i])for(j in a)print j}

Try it online!

{
for(;;a[++i])  # by only stating the array[element], that element is created in the array.
               # all not assigned variables starts at 0.
               # at first, i++ would return 0, and increment 1 to i;
               # but ++i increments 1 to i, and then return its new value.
  for(j in a)  # for every element existing in the array,
    print j    # prints the element j.
}

AWK, 37 bytes

Prints numbers in one line.

{for(;;a[++i])for(j in a)printf j FS}

Try it online!


AWK, 51 bytes

Prints numbers in a pyramid.

{for(;;a[++i])for(j in a)printf j+1 in a?j FS:j RS}

Try it online!

Arm Thumb (with libc calls), 34 bytes

Raw machine code

f7ff fffe is for libc calls which haven't been linked yet.

Needs to be loaded at an address that is not a multiple of 4, due to alignment requirements. Yes, it is counterintuitive, but it will make sense later.

2400 a707 3401 2501 0038 0029 f7ff fffe
3501 42a5 d9f8 200a f7ff fffe e7f2 7525
0020

Uncommented Assembly

        .thumb
        .globl main
        .thumb_func
main:
        movs    r4, #0
        adr     r7, str
.Lloop1:
        adds    r4, #1
        movs    r5, #1
.Lloop2:
        movs    r0, r7
        movs    r1, r5
        bl      printf
        adds    r5, #1
        cmp     r5, r4
        bls     .Lloop2
.Lloop2_end:
        movs    r0, #'\n'
        bl      putchar
        b       .Lloop1
str:
        .asciz "%u "

Explanation

Equivalent C code:

#include <stdio.h>
#include <stdint.h>
int main(void)
{
    uint32_t N = 0;
    for (;;) {
        ++N;
        for (uint32_t num = 1; num <= N; num++) {
            printf("%u ", num);
        }
        putchar('\n');
    }
    // Unreachable
}

Since we are never returning from main, I say, "to hell with calling convention" and just overwrite the callee-saved registers with our local variables. They won't know the difference. 😈

Specifically, I want r4 to be N (it is incremented before using), and r7 to be our printf string.

Unfortunately, we have an odd number of instructions, and adr can only load addresses that are 4 byte aligned, so we need to make main not be 4-byte aligned so the string is 4-byte aligned.

main:
        movs    r4, #0
        adr     r7, str

Begin printing the natural numbers. Increment N and start counting ℕ in r5.

.Lloop1:
        adds    r4, #1
        movs    r5, #1

printf("%u ", ℕ)

.Lloop2:
        movs    r0, r7
        movs    r1, r5
        bl      printf

Increment ℕ and loop while it is less than or equal to N.

        adds    r5, #1
        cmp     r5, r4
        bls     .Lloop2

After the second loop: putchar('\n')

.Lloop2_end:
        movs    r0, #'\n'
        bl      putchar

Jump back to the outer loop to increment N.

        b       .Lloop1

The printf string. This must be 4-byte aligned for adr, which we do with how we load main.

str:
        .asciz "%u "

Wolfram Language (Mathematica), 25 bytes

Do[Print@n,{m,∞},{n,m}]

Try it online!

-1 byte @att

Perl 5, 22 20 bytes

say while$_.=++$i.$"

Try it online!

PowerShell Core, 14 bytes

for(){1..++$i}

Try it online!

Will output the numbers of the sequence separated by a new line.

convey, 27 bytes

   >v
1","@"}
^+^<#-1
1+<<<

Try it online!

enter image description here

This counts down from successive numbers.

Common Lisp, 56 bytes

(do((i 1(1+ i)))(())(dotimes(j i)(format t"~v^~a "j j)))

Nested loop solution using the do macro for the outer loop and the dotimes macro for the inner loop. dotimes starts with 0 so format includes a specifier that checks whether it's a 0.

Nim, 47 bytes

var i=1
while true:
 for j in 1..i:echo j
 i+=1

Try it online! The footer makes it finite so the output can be observed.

Note that Nim doesn't have bigints, so this works only in theory (in accordance with our rules).

Zsh, 29 .. 19 bytes

Solution by @AdamKatz: Try it Online!

for ((;++i;))seq $i

19 bytes, port from bash : s(){seq $[++n];s};s
25 bytes (per @AdamKatz) : for ((;++i;))echo {1..$i}
25 bytes : for ((;;i++))shuf -i 1-$i
26 bytes (per @AdamKatz) : for ((;;))echo {1..$[++i]}
29 bytes : for ((i=1;;))echo {1..$[i++]}
I tried to use /dev/random for an alternative but it was a mess!

Julia, 47 46 bytes

Thanks to @user recommended to change true to 1>0.

a=[1];while 1>0;println(a);push!(a,last(a)+1);end

output:

[1]
[1, 2]
[1, 2, 3]
[1, 2, 3, 4]
[1, 2, 3, 4, 5]

Python 3, 45 bytes

a=[1]
while 1:
    print(a)
    a+=[a[-1]+1]

jq, 24 bytes

range(range(infinite))+1

Try it online! (requires the -n flag)

JQ is a stream-based language: every expression can return multiple values and when expressions are combined together the second one is flat-mapped over everything returned by the first. This makes it very easy to express infinite sequences.

infinite is a filter that ignores its input and returns a single infinite floating-point value.
range(n) is a filter that ignores its input and returns every positive integer smaller than n.
+1 adds one to each value in the result.

By default if we run this program it will try to read from STDIN (because each filter needs to take an input, even if it is ignored). Therefore we pass the -n flag to tell the interpreter to pass a single null value as the input to the filter.

Java (JDK), 54 bytes

A b;{b=(s,i)->{System.out.print(s+=i+++s);b.B(s,i);};}

Try it online!

Usually in lambda functions, this website doesn't include the "interface name =" part, but my answer was a declaration statement without the initialization, so I decided to include it. I couldn't find a rule about it.

My older, wrongly counted, 47 byte solution: Try it online!

(forced) inputs: a String with any delimiter (" "), and 1, where Y is the class it's in, b is the name of the interface object, and B is the method in the interface being used.

Rust + rand crate, 43 bytes

||loop{print!("{} ",rand::random::<u32>())}

Uses the rand crate to output random numbers, meaning every number is printed infinitely many times.

Burlesque, 6 bytes

,r1)ro

Try it online!

Explanation:

,       # Don't take implicit input from stdin
 r1     # Range from 1 to infinity
   )    # Map each value to
    ro  # Range from 1 to value 

Java (JDK), 61 bytes

v->{for(int i,j=2;;j++)for(i=0;++i<j;)System.out.println(i);}

Try it online!

Edit: Thanks @user for shaving off a few bytes and helping me learn something today! Big thanks to @KevinCruijssen for -2 bytes.

AutoHotkey, 36 bytes

Loop
Loop,%A_Index%
Send,%A_Index%`t

Output is via keyboard simulation so it will print in whatever the active window is.
Numbers are separated by tabs.

1   1   2   1   2   3   1   2   3   4   1   2   3   4   5   1   2   3   4   5   6   1   2   3   4   5   6   7   1   2   3   4   5   6   7   8   1   2   3   4   5   6   7   8   9   1   2   3   4   5   6   7   8   9   10  1   2   3   4   5   6   7   8   9   10  11  1   2   3   4   5   6   7   8   9   10  11  12  1   2   3   4   5   6   7   8   9   10  11  12  13  1   2   3   4   5   6   7   8   9   10  11  12  13  14  1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16  1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16  17  1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16  17  18  

Alternatively - and not in compliance with the challenge spec - if you prefer your numbers to be spoken rather than printed:

Loop
Loop,%A_Index%
ComObjCreate("SAPI.SpVoice").Speak(A_Index)

Julia, 27 bytes

f(n=1)=println.(1:n),f(n+1)

Try it online!

Befunge, 5 bytes

>1+?.

Try it online!

At each output, there is a 50% chance the current number will be printed and reset to 1, and a 50% chance that 2 will be printed and the current number will increase by some random odd number (following an exponential distribution). This can happen multiple times, so odd numbers can be outputted as well.

Every natural number has a nonzero probability of occurring, so it will eventually be printed infinitely many times.

Explanation

>1+?.
>      # Go east.
 1+    # Initialize a counter to 1.
   ?   # Go in a random direction.
       # If the instruction pointer goes west:
  +    # Add the top two stack elements together.
       # If there is a 2 on top, this adds it to the counter.
       # If not, this does nothing.
 1     # Create a new 1 on the top of the stack.
>      # Go east.
 1+    # Add 1 to get 2, which remains on top of the counter.
   ?   # Repeat.
       
   ?   # If the IP goes east:
    .  # Print and delete the top of the stack.
>      # Go east.
 1+    # Add 1.
       # If there was a 2 that was printed and the counter remains, the 1 gets added to it.
       # If the counter was printed instead, this creates a new 1.
   ?   # Repeat.

   ?   # If the IP goes north or south, it wraps around to the ? instruction and repeats.

Befunge-98, 14 bytes

]:.1-:0`j
]:+!

Try it online!

A determinstic solution, printing each range from 1 to n in descending order.

Explanation

]           # Turn right (to the south) and go to the second line.

]:+!      
]           # Turn right again (to the west).
   !        # Take the logical NOT of the secondary counter (which is now 0) to get 1.
  +         # Add the 1 to the main counter.
 :          # Duplicate the main counter to form a secondary counter.
]           # Turn right (to the north) and go to the first line.

]:.1-:0`j 
]           # Turn right (to the east).
 :          # Duplicate the secondary counter.
  .         # Print and delete the duplicate.
   1-       # Subtract 1 from the secondary counter.
     0`     # Is the secondary counter greater than 0?
       j    # If so, jump over the ] instruction and repeat the first line.
]           # If not, turn right (to the south) and go to the second line.

Raku, 18 bytes

.say for [\,] 1..*

Try it online!

[\,] 1..* generates the list of prefixes of the sequence of naturals. .say for just prints them.

Haskell, 17 bytes

[[1..x]|x<-[1..]]

Try it online!

Since the challenge seems to allow non-flat output, we can simply generate a list of the lists [1],[1,2],[1,2,3,],..., as suggested by @AZTECCO.

Haskell, 19 bytes

l=1:do x<-l;[x+1,1]

Try it online!

A recursively-defined infinite flat list with the ABACABA sequence 1,2,1,3,1,2,1,4,... (A001511).

A same-length variant:

l=(:[1]).succ=<<0:l

Try it online!

20 bytes

l=do x<-[1..];[1..x]

Try it online!

Counting up 1,1,2,1,2,3,1,2,3,4,..., but as a flat list.

R, 21 bytes

(also near-simultaneously identified by Robin Ryder)

while(T<-T+1)cat(T:0)

Try it online!

Similar to the example sequence, but each sub-series is reversed, and the initial value in each subseries is represented with an initial zero (so, 03 for 3, for instance).

If you don't like the initial zeros, then look at the previous version using show (below), or at Giuseppe's answer.


R, 23 22 bytes

Edit: -1 byte thanks to Robin Ryder

while(T<-T+1)show(1:T)

Try it online!

Outputs the sequence used in the example, plus an additional infinite number of copies of the number 1.
Each number is separated by either a space " " , a newline plus bracket, "\n[", or a bracket plus space "[ ".

2-bytes golfier (at time of posting, at least...) than the other two R answers...

R, 25 21 bytes

repeat T=print(T:0+1)

Try it online!

Prints 2..1, 3..1, 4..1 and so forth.

Thanks to Robin Ryder for -4 bytes.

This works because print invisibly returns its first argument.

Icon, 46 bytes

procedure f()
i:=0;|1&write(1to(i+:=1))&\z
end

Try it online!

Of course procedure ... end block makes it very verbose.

Too bad seq() doesn't work with bigints - otherwise I could've saved some bytes with

procedure f()
|1&write(1to seq())&\z
end

R, 26 25 24 bytes

-1 byte thanks to Dominic van Essen

repeat cat(rpois(9,9)+1)

Try it online!

Outputs a random infinite sequence of integers, drawn from the \$Poisson(9)\$ distribution (+1 to avoid outputting any 0s). They are output in batches of 9 at a time, for more "efficiency". Any positive value of the mean would work; using a mean of 9 maximizes the variance for 1-character numbers.

All numbers appear infinitely often in the sense that for any integer \$k\$, the expected number of occurences of \$k\$ in the first \$n\$ realizations goes to \$\infty\$ as \$n\to\infty\$:

$$E\left[\sum_{i=1}^n\mathbb{I}_{X_i=k}\right]\xrightarrow[n\to\infty]{}\infty.$$

The calls to cat mean that there integers within one batch of 9 are separated by spaces, but there is no separator between batches. The vast majority of 3- and 4-digit numbers in the output are due to this artefact, but there is a theoretical guarantee that such numbers (and larger numbers) will be output eventually, at least if we assume that the underlying random number generator is perfect.


For a larger variance, we can follow Giuseppe's suggestion for the same byte count:

repeat cat(1%/%runif(9))

Try it online!

This induces more 1s and more large numbers (including some very large numbers thanks to the cat artefact). Again, number of occurrences of any integer goes to infinity when the size of the output goes to infinity.


Two other R answers come out shorter, using deterministic methods: Giuseppe's and Dominic van Essen's

Pyth, 4 bytes

f!pS

Try it online!

Explanation

f!pS
      : lambda T:
   S  :    range(1, T)
  p   :    print and return the range
 !    :    logical negate the range
f     : Find first natural number input to function that returns a truthy value

Wolfram Language (Mathematica), 31 bytes

Print@Floor[Sec@n^2]~Do~{n,∞}

Try it online!

Not quite as short as the other Mathematica answer, but implements a different and more mathematically interesting sequence, namely the integer part of \$\sec^2n\$; the fact that this includes every natural number infinitely often follows from the fact that the integers are uniformly distributed modulo \$\pi\$.

Python 2, 31 bytes

R=1,
while 1:print R;R+=len(R),

Try it online!

Thanks to @Danis for saving a byte here over R+=R[-1]+1,. This

Prints:

(1,)
(1, 1)
(1, 1, 2)
(1, 1, 2, 3)
(1, 1, 2, 3, 4)
(1, 1, 2, 3, 4, 5)
    ...

Accumulates a list of number from 1 to n (except 1 appears twice) each time appending the last element plus one.

32 bytes

R=[1]
for x in R:print R;R+=x+1,

Try it online!


Python 2, 30 bytes (conjectured)

n=2
while 1:print~-2**n%n;n+=1

Try it online!

The sequence of \$2^n \bmod n\$ (A015910) is conjectured to take on all values \$k \geq 0\$ except \$k=1\$. I don't know if it's also conjectured that each value appears infinitely many times, but it seems consistent with known solutions for specific values.

We instead compute \$(2^n-1) \bmod n\$, which makes \$0\$ rather than \$1\$ be the only missing value (if the conjecture holds).

Looking at the output, you might think that \$2\$ is never output, but it in fact does appear first for \$n=4700063497\$ and for progressively higher values in A050259.


Python 2, 33 bytes

R=[1]
for x in R:print x;R+=x+1,1

Try it online!

This is longer, but it's pretty nifty, printing the ABACABA sequence.

C (gcc), 52 49 44 bytes

Saved 5 bytes thanks to AZTECCO!!!

f(i,j){for(j=1;printf("%d ",j--);)j=j?:++i;}

Try it online!

JavaScript (Browser), 40 bytes

f=(x=1)=>setInterval(_=>alert(x,f(x+1)))

Not very competitive answer :(

JavaScript (V8), 26 bytes

for(a=b='';;)write(a+=--b)

Try it online!

Character - used as a separator and the output starts with it, so I'm not really sure if this is acceptable.

Bash, 20 bytes

seq inf|xargs -l seq

Try it online!

Factor, 32 bytes

1 [ dup bit-count . 1 + t ] loop

Try it online!

Loops over the positive integers and prints their bit count (the number of 1 bits, a.k.a. popcount) forever. Outputting nth term would be simply 9-bytes bit-count. (I checked that the function works with bigints.)

Uses the same logic as Neil's Charcoal answer that there are infinitely many numbers whose digit sum equals n, except that this one uses bits instead. More precisely, for any positive integer n, \$2^m(2^n-1)\$ for any non-negative integer m has exactly n bits on, so the sequence contains infinitely many n's for any n.

JavaScript (V8), 29 bytes

for(n=k=1;;)print(n=--n||k++)

Try it online!

JavaScript (V8), 34 bytes

Saved 2 bytes thanks to @tsh

for(n=k=0;;)print(n=n<k?n+1:++k/k)

Try it online!

Returning the n-th term would be 31 bytes:

n=>(m=(8*n+1)**.5-1>>1)*~m/2-~n

Try it online!

Stax, 5 bytes

VImRJ

Run and debug it

Explanation

VImRJ
VIm   map 1..infinity to
   R  range 1..i
    J join with spaces
  m   print each iteration

PHP, 30 bytes

<?for(;;)echo--$j?:$j=++$i,~_;

Try it online!

The numbers are separated by a no-break space (U+00A0).

C (gcc), 43 bytes

i;main(j){for(;;)printf("%d ",j=--j?:++i);}

Try it online!

Charcoal, 8 bytes

W¹«I⊕ⅉD⸿

Try it online! Link is to verbose version of code. Works by repeatedly printing the next number to the canvas and then dumping the entire canvas.

2 bytes for a version that prints the \$ n \$th term of a sequence:

IΣ

Try it online! Explanation: Simply prints the digital sum of the input. Given any natural number \$ n \$, all the values of the form \$ \frac { 10 ^ n - 1 } 9 10 ^ m \$ have a digital sum of \$ n \$ for every \$ m \$, thus each natural number appears infinitely often.

Ruby, 17 bytes

loop{p *1..$.+=1}

Try it online!

Rust, 54 bytes

(2..).for_each(|x|(1..x).for_each(|y|print!("{} ",y)))

Try it online

APL (Dyalog Unicode), 12 11 bytes (SBCS)

Saved 1 byte thanks to @ovs

{∇1+⍴⎕←⍳⍵}1

Try it online!

This one also uses the sequence from the question.

AWK, 34 bytes

{for(;;++i)for(j=0;j++<i;)print j}

Try it online!

Octave, 29 28 bytes

do disp(fix(1/rand)) until 0

Try it online!

This outputs a sequence \$(x_k)\$ of independent, identically distributed random natural numbers. Each value \$x_k\$ is obtained as \$1/r\$ rounded towards zero, where \$r\$ has a uniform distribution on the interval \$(0,1)\$.

For a given index \$k\$, and for any \$n \in \mathbb N\$, there is a nonzero probability that \$x_k=n\$ (ignoring floating-point inaccuracies). Therefore, with probability \$1\$ every \$n\$ appears infinitely often in the sequence \$(x_k)\$.

J, 13 bytes

$:@,~[echo@#\

Try it online!

Outputs 1, 1 2, 1 2 3 4, 1 2 3 4 5 6 7 8, etc, with every number on its own line.

Python 2, 24 33 bytes

Added 9 bytes to fix an error kindly pointed out by caird coinheringaahing.

n=1
while 1:n+=1;print range(1,n)

Try it online!

Brachylog, 4 bytes

⟦₁ẉ⊥

Try it online!

  ẉ     Print with a newline
⟦₁      the range from 1 to something,
   ⊥    then try again.

Jelly, 4 bytes

‘RṄß

Try it online!

I think this outputs all numbers an infinite number of times, but because it's a different output format, I'm not 100% sure

How it works

‘RṄß - Main link. Left argument is initially n = 0
‘    - Increment
 R   - Range
  Ṅ  - Print
   ß - Recursively run the main link

For n = 0, ‘RṄ outputs [1]. We then recurse, using n = [1]. ‘RṄ then outputs [[1, 2]], and we recurse again, using n = [[1, 2]], which outputs [[[1, 2], [1, 2, 3]]] etc.

sed 4.2.2, 20

:;s/(1*).*/1\1 &/p;b

Try it online!

Output is in unary, as per this meta consensus.

Bash + GNU Coreutils, 20

seq -fseq\ %g inf|sh

Try it online! - Times out after 60 seconds.

Husk, 2 bytes

ḣN

Try it online!

First Husk answer! Also uses the sequence in the question

How it works

ḣN - Main program
 N - The infinite list [1, 2, 3, ...]
ḣ  - Prefixes; [[1], [1, 2], [1, 2, 3], ...]

05AB1E, 2 bytes

∞L

Try it online! The footer formats the output like the example from the post.

pushes a list of all natural numbers, L takes the range [1 .. n] for each number.

Scala, 23 bytes

Stream from 1 map(1 to)

Try it online

An infinite Stream of IntRanges. Uses the sequence from the question.