# Shortest code to produce infinite output

Write the shortest code you can that produces an infinite output.

That's all. You code will only be disqualified if it stops producing output at some point. As always in code golf, the shortest code wins.

Here's a list of answers that I think are really clever, so they can get credit:

var QUESTION_ID=13152,OVERRIDE_USER=8611;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>

• All answers disqualified because at some point the Earth will be swallowed by the sun, and at some point the universe will die :P – Doorknob Nov 9 '13 at 20:00
• Does "infinite until your computer crashes" count? <_< – Izkata Nov 10 '13 at 1:39
• If I write mine in Piet, can I count the pixels of the text the other programs used? I believe the smallest possible repeating Piet program would be 6 pixels. That beats Befunge if "off" pixels still count. – DampeS8N Nov 12 '13 at 20:27
• @Izkata So any answer that crashes your computer is also allowed :D – ɐɔıʇǝɥʇuʎs Jul 11 '14 at 20:11
• @Doorknob So really, the challenge is to produce infinite output in a finite amount of time. Sounds easy enough. – Sanchises Apr 10 '15 at 21:15

# Zozotez LISP: 7

When started with the minimal interactive session dictated in the documentation:

(:'r p)


How it works is that it redefined read so the REPL prints what print returns rather than keyboard input. The never ending output is continious lines of: Zozotez-moi~>NILNIL

When started with the full interactive session it gets longer, but does the same (10 bytes):

(:'read p)


Without a bootstrap Zozotez does just (eval(read)) thus we need to implement a loop in one expression (16 bytes):

((:'z(\()(p)(z))))


The : is set to it binds z to the lambda expression (\()(p)(z)), when called without arguments calls print (p) with default argument NIL, then calls z (recurses).

: returns the value (the function) so wrapping it all in parenthesis makes the initial call.

# Common Lisp: 15

(loop(print())) ; prints infinite lines of NIL


# Racket: 21

(let z()(print'N)(z))


Works similar. The names let makes and calls the proecdure l that takes no arguments. The body prints N, then recurses. print without arguments displays data quoted so it prints 'N'N'N....

# Scheme: 23

(let z()(display'N)(z))


Same as Racket version only that display is used which don't quote output. NNNN...

## Thue, 19

b::=~1
a::=ba
::=
a


The code prints an infinite stream of 1's.

The code is quite simple and easy to understand.

• b can be expanded as "output 1" (then b is replaced with empty string)
• a can be expanded as/replaced by ba
• ::= on its own ends the list of rules
• a on the last line represents the initial state.

# Brainfuck - 6/4

Brainfuck does this easily:

-[.>-]


If we assume that the interpreter didn't zero the cells on startup but instead gave us already-initialised cells, the count goes down by two:

[.>]

• Why not just -[.]? – Justin Apr 23 '14 at 18:51
• Hm, I haven't thought of that really, good idea. – Darkgamma Apr 24 '14 at 13:34
• But that is actually a duplicate of another answer here. – Justin Apr 24 '14 at 17:32
• I haven't seen the others before now, really, though even just -[.] is shorter than the other answers given. – Darkgamma Apr 25 '14 at 12:06
• You should really go through other answers, especially of the same language, before posting. – Justin Apr 25 '14 at 15:19

# Bash, 9 characters

echo 1;$0  Because the$0 variable always holds the filename.

• I'm not sure this will really have an infinite output. You'll run out of memory before reaching infinity. echo 1;exec $0 would be better (but also has more characters). – gniourf_gniourf Apr 26 '14 at 9:22 ## C# (16) Directly executable in LinqPad: for(;;)0.Dump();  # Ruby: 9 charecters loop{p 1} p 1 is equivalent to puts 1.inspect ## Mathematica, 11 bytes (invisible) or 17 bytes (visible) Clearly not going to win here, but it works For[,0<1,1]  If you actually want to see the characters streaming down the screen, use For[,0<1,Print@1]  (20 bytes). I had thought I might do well with Range@∞  or even 1~Table~{∞}  But to my surprise, the Kernel checks for infinite bounds and disallows them. • You'll definitely need the Print version. But that can be golfed further: 1>0 is shorter than True, Print@1 is shorter than Print[1] and you can leave out one of the two consecutive commas to use the 3-argument version of For. – Martin Ender Sep 2 '14 at 14:41 • Echo@1 is shorter than Print@1. – Roman Jul 23 at 13:01 Shell, 16 Chars cat /dev/urandom  • also grep -r / . for 12 bytes – roblogic Jul 29 at 10:36 # Pyth, 2 #G  (or # followed by any normal variable, actually). # is while True. Variables are printed implicitly, and since G is 'abcdefghijklmnopqrstuvwxyz', that gets printed infinitely. • This makes me want to learn Pyth myself. – DJgamer98 Nov 13 '15 at 8:33 # x86 machine code, 6 bytes b40e cd10 ebfc  Assembly version of the code: mov ah, 0Eh; bios teletype output code_golf: int 10h; print character(ascii 0) jmp code_golf; loop  This code constantly prints ASCII 0 (NULL). This was run using DOSBOX • What OS is this for? (DOS? Linux?) Can you put that in your answer? – tbodt Mar 5 '15 at 22:24 • @tbodt I did specify: x86. But, I can see how some people might be confused so I included how I ran the code. – SirPython Mar 5 '15 at 23:14 Piet (135 codels/pixels) Prints an infinite sequence of$ signs (arbitrary, could've been anything. Loaded in the upper right corner of course).

Run with npiet -v11 the.gif

• In Piet, pixels count as characters. – tbodt Feb 2 '14 at 23:40
• @tbodt - It's 135 pixels, but 112 bytes (if I'm not mistaken) -- byte-count is supposed to be the code-golf criterion. – r.e.s. Feb 3 '14 at 0:24
• what if you save it in a different image format? for piet, I count number of pixels. – tbodt Feb 3 '14 at 0:26

# Jelly, non-competing

2 bytes This answer is non-competing, since the challenge predates the creation of Jelly.

Ȯß


Try it online!

### How it works

Ȯß  Main link. Implicit argument: 0

Ȯ   Output/print the implicit argument.
ß  Recursively call the main link.
Thanks to tail call optimization, this results in an actual infinite loop.


# APL, 6 4 bytes

→⍞←1


A traditional style APL function, so even works on all legacy APLs.

# Desmos, 1 byte

x


Graphs y=x forever.

• Look, submitting Desmos answers is my job :P Good job anyway. – Benjamin Urquhart Jun 1 at 17:48

## APL, 4 bytes

1
→1


This code must be put in a function, since the →(goto) operator has only sense in a function.

# Oration, 21 bytes (non competing)

to iterate, 1
listen,


40 bytes:

to iterate, 1
listen,
capture,
that's it


The first does print() (but it's python 2, so prints infinite ()), the second does print('') (the capture begins a string and the that's it ends it).

# Sesos, 2 bytes (non-competing)

0000000: 2c06                                              ,.


Prints an infinite amount of ones.

Try it online! Check Debug to see the generated binary code.

### How it works

The binary file above has been generated by assembling the following SASM code.

set numout ; Switch to numeric output

add 1      ; Set the current cell to 1.
put    ; Print the integer in the current cell to STDOUT.
; (implicit jnz)
;     If the integer in the current cell is non-zero,


# Retina, 4 bytes (non-competing)

The language is newer than the challenge.

+:0


Try it online

Doesn't match, so output 0, then it does match so output 1, now it doesn't so output 0, etc...

• A paradox in action :) – ETHproductions Nov 15 '16 at 23:05

# Cubix, 2 bytes

.O


Test it online!

Cubix is a stack-based 2D language, created by me in March 2016. Cubix differs from ordinary 2D languages in that it's not strictly 2D: the code is wrapped around a cube. This program wraps to this cube net:

   .
>O . . .
.


where the IP (instruction pointer) starts at the arrow. O outputs the item on top of the stack as a number; if the stack is empty, it outputs 0. . is a no-op.

When the IP reaches the right side of the cube net, it simply wraps back around to the left and runs O again. Thus, this code outputs 0 forever.

# Commodore Basic, 5 bytes

1?:R╭


PETSCII substitution: ╭ = SHIFT+U

Prints a newline, then runs itself. Forever.

# Emojicode, 41 bytes

🏁🍇🔁👍🍇😀🔤.🔤🍉🍉


I've got two:

## C - 272624 bytes

main(){for(;;)puts("");}


This one infinitely prints \n, due to the behavior of puts(3)

## Brainfuck - 134 bytes

+[.]


This one infinitely prints the invisible Start Of Heading control character.

(Thanks to scottinet, Sylwester and Erik the Golfer for suggestions that helped shorten the answer)

• I have something shorter. – tbodt Jan 30 '14 at 20:22
• @tbodt Oh, I didn't know null counted. I thought it had to be visible – Braden Best Jan 30 '14 at 20:33
• @B1KMusic, If you have 2 (or more) answers, it's best to post them separately. – gnibbler Feb 2 '14 at 9:38
• The BF answer is already posted. – NoOneIsHere Nov 25 '16 at 3:23
• Use puts("") for -2 bytes (prints \n infinitely) – scottinet Sep 1 '17 at 18:46

# Chip-8, 5 bytes

Sound output counts, right?

0x6F 0xFF 'set register 15 to 255
0xFF 0x18 'set sound timer to the value of register 15
0x12      'jump to first instruction (second byte is 00 so it can be omitted)


If drawing graphics counts, 3 bytes:

0xD0 0x0F 0x12


# Shakespeare Programming Language, 116 bytes

.
Puck, a pig.
Page,.
Act I:.
Scene I:.
[Enter Puck and Page]
Page:
[Exeunt]


Will output -1 forever.

• What interpreter are you using? This doesn't seem to work on the official one. (nvm, found it) – Jo King Aug 27 '18 at 7:38

# TI-Basic, 5

Pause


It does produce infinite output; in the top right hand corner, the pixels are alternating ;)

# Game Maker Language, 11

while(1){a}


The a produces errors infinitely ;)

• Well, the "Pause" token in TI-Basic (z80, at least), is actually 1-byte in memory :) (see tibasicdev.wikidot.com/pause) – Adriweb Sep 2 '14 at 19:11
• Submitting the TI-BASIC entry is like saying any zero-character command-line entry counts because the cursor is blinking. – lirtosiast Jun 14 '15 at 2:12
• The last one is bad. The code itself doesn't run for infinite times, but it's called infinite times – l4m2 Apr 2 '18 at 2:45
• @l4m2 Good point, I'll take that one out. – Timtech Apr 2 '18 at 14:18
• This should be two answers. – 12Me21 Jun 5 '18 at 13:40

# HTML + JavaScript, 35 bytes

This alerts repeatedly. For some reason, it alerts 8. It also produces a 404 error in the console each iteration.

<img onerror=alert(this.src=x) src=


JSFiddle

This is 32 bytes, but is far less interesting:

<img onerror=for(;;)alert() src=


# Alchemist, 10 bytes

_->_+Out_a


Try it online!

### Explanation

Initially the universe contains the _-atom, there is only one reaction consuming _ and creating a new _ with the side-effect of printing a. This will go on until the real universe terminates.

# Lean Mean Bean Machine, 5 bytes

O
$~  Try it online! Endlessly output 0 O spawns a marble, which drops and runs the operation there each tick. New marbles have a value of 0. $ prints the marble's value.
~ teleports the marble to the top of the current column.

000000
400000
120000
010000


Continuously prints 0s.

• Now that's a long language name – Benjamin Urquhart Jun 1 at 17:47

## bitch, 3 characters

Yet another answer(am I supposed to be doing that?)

>/<
`

This program outputs infinite 0's to the console.