49
\$\begingroup\$

Write a script that outputs A to stdout infinitely.

There should be no newlines or separators between the characters.

Standard loopholes apply.

This is . The shortest solution in each language wins.

\$\endgroup\$
20
  • 10
    \$\begingroup\$ @FryAmTheEggman I respectfully disagree with this being marked as duplicate. This has a few almost (but not quite!) trivial distinctions from the other questions. For example, printing to stdout without printing a new line, and in the other challenge, looping without output \$\endgroup\$
    – Tornado547
    Feb 29, 2020 at 1:41
  • 3
    \$\begingroup\$ @FryAmTheEggman The other challenge clearly states "producing no output". This is not "producing no output". \$\endgroup\$
    – S.S. Anne
    Feb 29, 2020 at 1:46
  • 2
    \$\begingroup\$ @FryAm In Brainfuck, the size is more than 5 times that of the original program. In some languages, output without newlines is hard, especially with sed. I had to use the -z flag just to even remove one. \$\endgroup\$
    – S.S. Anne
    Feb 29, 2020 at 15:36
  • 18
    \$\begingroup\$ "Infinite output" is significantly different from "a specific char infinitely many times without new lines". I don't think this is a duplicate. Let's reopen it if this comment gets four upvotes \$\endgroup\$
    – Luis Mendo
    Feb 29, 2020 at 22:00
  • 3
    \$\begingroup\$ @Tornado547 If you update the requirement, you need to notify current answers. Alternatively, you can keep the infinite output requirement, and include a sentence saying something like "The code should theoretically produce infinite output, given enough time and memory, and disregarding any data-type limitations. It is acceptable if in practice the output stops due to some of those limitations" \$\endgroup\$
    – Luis Mendo
    Mar 1, 2020 at 20:56

175 Answers 175

1
\$\begingroup\$

Scala, 20 bytes

while(print('A')!=0)
\$\endgroup\$
1
\$\begingroup\$

CJam, 7 bytes

'A{_o}h

CJam loops are surprisingly expensive as there are no markers, and since there's no infinite loop function, we need to make sure there's always a spare truthy A on the stack for our do-while loop.

Try it online

Explanation:

'A        Push 'A' to the stack
  {  }h   Loop while top of stack is true
   _      Duplicate the A
    o     Pop and output the A w/ no newline
\$\endgroup\$
1
\$\begingroup\$

Oak, 29 Bytes

fn main(){while(1){prc!(65)}}

This may have to be changed to fn main(){while(1){prc!('A')}} once num and char are no longer interchangable, but for now it works.

\$\endgroup\$
1
\$\begingroup\$

Perl 6, 16 bytes

loop {print "A"}

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Neim, 5 bytes

ͻ    # Infinite loop
 (   # Decompress base 255
  A  # A
 )   #
   B # Compress number to base 255

Runs only 6 times

Try It Online!

\$\endgroup\$
1
\$\begingroup\$

StupidStackLanguage, 11 bytes

avqviiimtfu

Try it online!

Explanation

a - push 0 to stack
v - add 5
q - duplicate
viii - add 8 (making 13)
m - multiply top 2 items (13x5 = 65)
t - start bf style loop
f - print character
u - end bf style loop
\$\endgroup\$
1
\$\begingroup\$

Husk, 3 bytes

∞'A

Try it online! Creates an infinite list of 'A characters and prints it.

\$\endgroup\$
1
\$\begingroup\$

C#, 62 bytes

class P{static void Main(){for(;;)System.Console.Write('A');}}
\$\endgroup\$
1
\$\begingroup\$

Deadfish~, 4014 bytes:

{iiiiii}iiiii{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{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}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

Sets the accumulator to 65, then prints as character 102000 times = far beyond the lifespan of the universe.

There's no way to do anything infinitely in Deadfish~, so 102000 times should be enough.

\$\endgroup\$
1
\$\begingroup\$

VBScript, 31 bytes

Do 
WScript.StdOut.Write("A")
Loop
\$\endgroup\$
1
\$\begingroup\$

C# 9, 33

for(;;)System.Console.Write('A');
\$\endgroup\$
6
  • 1
    \$\begingroup\$ You can drop this to 26 bytes by removing the full qualification: for(;;)Console.Write('A');. \$\endgroup\$ Aug 19, 2021 at 13:47
  • \$\begingroup\$ @Tacoタコス I'm not a great fan of that as this wouldn't really compile when you'd put it in VS19 for example. \$\endgroup\$
    – baltermia
    Aug 19, 2021 at 16:48
  • \$\begingroup\$ By default System is added as a using directive with every class file generated. So creating a new console app to test this will include the System namespace by default. Plus, you can add a web link for testing with DotNETFiddle which also includes System by default with new fiddles. \$\endgroup\$ Aug 19, 2021 at 17:07
  • \$\begingroup\$ Not saying you have to reduce it either, just wanted to let you know :) \$\endgroup\$ Aug 19, 2021 at 17:15
  • 1
    \$\begingroup\$ @Tacoタコス I wanted to have a file only contain the string above which is possible with C# 9 and .NET Core 5. The System using is not added by default. \$\endgroup\$
    – baltermia
    Aug 19, 2021 at 19:28
1
\$\begingroup\$

Barrel, 9 bytes (or 8 with newer instruction)

^A¤p←1

Explanation:

^A     // Sets the accumulator to the ASCII codepoint of 'A'.
  ¤ ←1 // Creates a jump target and jumps back to it.
   p   // Prints the accumulator as a character value.

Since the command will implicitly push the current location onto the location pointer stack, this program will use lots of system memory. In fact, on my system it used about one megabyte of RAM per second. To overcome this, I've since implemented the operator, which jumps without pushing (and therefore removes the possibility of RAM overflow). It makes the command look like this: ^A¤p↰1

This could be 8 bytes now that I have implemented the infinite loop that I'd thought about implementing: ^65#∞p In this case, the #∞p would define a loop which would print the character value infinitely. However, since the infinity command may have been inspired by this (I actually forget) and the command is newer than the answer anyway, I'll refrain from changing my answer.

\$\endgroup\$
1
  • \$\begingroup\$ Welcome to Code Golf! \$\endgroup\$
    – Makonede
    Apr 14, 2021 at 22:05
1
\$\begingroup\$

Nim, 26, 25 bytes (Credits to @hyper-neutrino)

while 1>0:stdout.write'A'

Try it online!

Not great, but not too shabby.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ You can remove the space after stdout.write. \$\endgroup\$
    – hyper-neutrino
    Jun 28, 2021 at 20:24
  • \$\begingroup\$ Thanks. Should have seen that. \$\endgroup\$ Jun 28, 2021 at 20:29
1
\$\begingroup\$

Rattle, 7 bytes

65|[,]0

Try it Online!

If you run this on the online interpreter, you'll get an error message saying the code timed out with no output. That's only due to how this online interpreter is set up* - if you run this locally, it will never stop printing AAAAAAAAAAAAAAAAAAAAAAAA.... Online CPU-seconds are expensive!

*it's supposed to still give output even if an error gets thrown because it is an interpreted language, but I don't know how to set that up properly on the website. So as of right now, output in the online version only gets printed if the program exits successfully...

Rattle prints the top of the stack implicitly upon exit. However, this code will never exit. If you run this on the online interpreter with a finite loop (change the 0 to 100 or something), you'll notice that 65 gets printed at the end. Of course, the end of infinity doesn't exist, so this code is still valid.

Explanation

65|             hard-coded input (Rattle's equivalent to a variable declaration)
   [...]0       infinite loop
     ,          prints the ASCII character of the value on top of the stack (A = ASCII 65)
\$\endgroup\$
1
\$\begingroup\$

Daoyu, 13 instructions, 7 bytes

There's two! Each instruction is a hex, so two instructions fit in a byte.

$$$(([]!)/(/[]!)):><
OPLEV 0:
$$$                   Allocate 8 bits of memory to the bit tape
   (([]!)/(/[]!))     Set the bit tape to 01000001
                 :><  Print the bit tape, and loop to the beginning
OPLEV 1:
...                   NOP
   ((().)/(/().))     Moves around the bit tape with no effect
                 :><  Print the bit tape, and loop to the beginning

This one is simpler, but it's 20 instructions and an extra byte. The first time the program loops, the operation level is 0, and it runs the first program, which allocates memory, sets the bit tape to 'A', and prints. Every other time it loops it just prints the bit tape.

%!)))):((((><
%!             Acts as NOP, encodes 'A'
  ))))         Moves data reader to '%!'/'A'
      :((((><  Prints, resets position, and loops to beginning

This one reads its own source code, and is a few bytes smaller. The operation level does change, but it doesn't really affect any of the program. When attempting to MERGE ()) while selecting the entire but tape, which is the original state of the program, the data reader moves to the parent bit tape, which is the program's source code. The program navigates to the %!, prints it as 'A', and loops.

\$\endgroup\$
1
\$\begingroup\$

Deorst, 6 bytes

oA
#EO

Try it online!

Explanation:

oA   # Push 'A'
#    # Forever:
 EO  #   Print without newline
\$\endgroup\$
1
\$\begingroup\$

WedgeScript, 4 bytes

'A|o

Explanation:

'A    Pushes the character literal A to the stack\
|     Loop the rest of the code infinitely\
o     Output

Yes, Wedgescript is a custom language made by me, here is the repo with interpreter install instructions: https://github.com/WedgeScript/WedgeScript

\$\endgroup\$
1
\$\begingroup\$

JavaScript (Node.js), 33 32 bytes

-1 byte thanks to @Luke_

for(;;)process.stdout.write('A')

Try it online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ You can use for(;;) instead of while(1) to save 1 byte : ) \$\endgroup\$
    – Luke_
    Aug 6, 2021 at 13:13
1
\$\begingroup\$

Japt, 10 bytes

{Oo'A}g1/0

Try it online!

Explanation

{Oo'A}a
{          // Function
 Oo'A      //    Output 'A'
     }     // End Function
      g1/0 // Call infinite times
           // (Japt's O.o() method returns undefined)

Japt, 7 bytes

As pointed out by @Shaggy due to how a is implemented this will print A only 1e8 times

{Oo'A}a

Try it online!

Explanation

{Oo'A}a
{       // Function
 Oo'A   //    Output 'A'
     }  // End Function
      a // Call repeatedly until it returns a truthy value
        // (Japt's O.o() method returns undefined)
\$\endgroup\$
2
  • \$\begingroup\$ This won't run forever as Japt's F.a() method uses a for loop that only runs a maximum of 1e8 times, as can be seen here. \$\endgroup\$
    – Shaggy
    Aug 6, 2021 at 13:23
  • \$\begingroup\$ ... or, more legibly in v2, here. \$\endgroup\$
    – Shaggy
    Aug 6, 2021 at 13:24
1
\$\begingroup\$

Arduino, 63 bytes

void setup(){Serial.begin(300);}void loop(){Serial.write('A');}

Not sure how much explaining I need to do here. Arduino has an infinite loop built-in, so just write one 'A' to the Serial output inside of it. Equally valid would be Serial.print('A'); and Serial.print("A");, and I think Serial.write("A"); should work as well. It's all just a matter of preference.

\$\endgroup\$
1
\$\begingroup\$

Vyxal, 4 bytes

The try it link has the 5 flag to prevent it from freezing up forever.

{\A₴

Explanation

{    - While loop
 \A  - Push "A"
   ₴ - Print without newline

Try it Online!

\$\endgroup\$
1
\$\begingroup\$

INTERCAL (C-INTERCAL), 61 bytes

DO,1<-#9DO,1SUB#1<-#126DOCOMEFROM#9PLEASEREADOUT,1(9)DO,1<-#9

Try it online!

\$\endgroup\$
1
\$\begingroup\$

CLC-INTERCAL, 48 bytes.

DO;1<-#1DO;1SUB#1<-#20DOCOMEFROM#9(9)DOREADOUT;1

(Don't) Copy and paste to try it online! It is very recommend to replace COME with NEXT, as output suppression may be weak.

\$\endgroup\$
1
\$\begingroup\$

ErrLess, 3 bytes

'A?

Explanation

'A { Push 'A' to the stack }
?  { Output the top element of the stack as a character }

The Instruction pointer loops when it reaches the end of the program.

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Python 3, 23 bytes

while[print(end="A")]:0

Try it online!

\$\endgroup\$
1
1
\$\begingroup\$

Lexurgy, 17 bytes

a propagate:
*=>A

Forever replaces an empty string with A.

\$\endgroup\$
1
\$\begingroup\$

Desmos with actions, 44 bytes

Code in ticker:

s_{tdout}\to join(s_{tdout},65)

Code in list (the actual area where you can enter equations):

s_{tdout}=[]

It outputs the ascii code for A

Link: https://www.desmos.com/calculator/u1fynzwbuf

\$\endgroup\$
1
  • \$\begingroup\$ This can be significantly golfed. First, you can simply let the output list be contained in one character variable like o (for output), instead of s_{tdout}. Also, \to can be replaced with ->. Taking these golfs into consideration, the code would be 18 bytes \$\endgroup\$
    – Aiden Chow
    Apr 26 at 7:03
1
\$\begingroup\$

Underload, 10 bytes

((A)S:^):^

Try it online!

Explained:

(    :^):^ While true...
    S      Print
 (A)       The string "A"
\$\endgroup\$
1
\$\begingroup\$

rusty_deque, 19 bytes

'A'~{dup~ow~}~loop~

Pretty much a duplicate of my "Shortest code to produce infinite output" answer.

\$\endgroup\$
0
\$\begingroup\$

x86 machine code - 14 bytes

So, yeah I'm using write() system call to print A characters without \n

     6                                  scream:
     7 00000000 6A41                      push 0x41
     8 00000002 31DB                      xor ebx, ebx
     9 00000004 89E1                      mov ecx, esp 
    10 00000006 B201                      mov dl, 0x1 
    11 00000008 B004                      mov al, 0x4 
    12 0000000A CD80                      int 0x80
    13 0000000C EBF2                      jmp scream

This is output using strace :

write(0, "A", 1A)                        = 1
write(0, "A", 1A)                        = 1
write(0, "A", 1A)                        = 1
write(0, "A", 1A)                        = 1
<repeat> ..
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.