55
\$\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
    Commented Feb 29, 2020 at 1:41
  • 4
    \$\begingroup\$ @FryAmTheEggman The other challenge clearly states "producing no output". This is not "producing no output". \$\endgroup\$
    – S.S. Anne
    Commented Feb 29, 2020 at 1:46
  • 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
    Commented 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
    Commented Mar 1, 2020 at 20:56
  • 3
    \$\begingroup\$ I'm surprised no one mentionned this helpful uncyclopedia page yet \$\endgroup\$
    – Oddrigue
    Commented Mar 4, 2020 at 10:29

203 Answers 203

1
3 4 5
6
7
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
  • 2
    \$\begingroup\$ 22 bytes \$\endgroup\$
    – math scat
    Commented Jan 29, 2022 at 11:47
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
  • 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
    Commented Apr 26, 2022 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\$

makina, 14 bytes

>Pv
^>OtA;
^<<
\$\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\$
1
\$\begingroup\$

A0A0, 44 40 bytes

A0A0
A0C3G1G1A0
A0P65A0
A0A1G-3G-3A0
G-3

Forms a standard infinite loop, with the three actual instructions to be executed in the middle.

P65 ; prints 'A'

Edit: Optimize by 4 bytes. The loop does not need three instructions to function, so we can drop two instructions, totalling four bytes.

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

Fig, \$4\log_{256}(96)\approx\$ 3.292 bytes

(;/A

See the README to see how to run this

(;/A # Takes no input, obviously. Tbh I have no idea what to write on the first comment line
(    # Repeat forever:
 ;   # Print
  /A # "A"
\$\endgroup\$
1
1
\$\begingroup\$

Prolog (SWI), 18 bytes

a:-put(65),a.
?-a.

Try it online!

-1 from Steffan.

\$\endgroup\$
3
  • \$\begingroup\$ Instead of 'A', just use 65 \$\endgroup\$
    – naffetS
    Commented Sep 7, 2022 at 16:12
  • \$\begingroup\$ Ouch, repeat is one byte longer \$\endgroup\$
    – Jo King
    Commented Sep 8, 2022 at 2:18
  • \$\begingroup\$ yeah, tried that before recursion \$\endgroup\$
    – Razetime
    Commented Sep 8, 2022 at 3:20
1
\$\begingroup\$

yup, 33 31 bytes

0eee:0~--:0~--0:ee-0ee--0e-{:@}

Pushing the 65 can perhaps be shortened.

Try it online.

Explanation:

yup has a limited amount of operators, so almost everything in the program is to push 65:

0        # Push a 0
 e       # exp(0) = 1
  e      # exp(1) = 2.718...
   ::    # Duplicate this 2.718... twice
     ]]  # Rotate them both to the bottom of the stack
       e # exp(2.718...) = 15.154...
:        # Duplicate this 15.154...
 0       # Push another 0
  ~      # Reverse the top two values
   -     # Subtract them: 0-15.154... = -15.154...
    -    # Subtract again: 15.154...--15.154... = 30.308...
:0~--    # Do the same: 30.308...--30.308... = 60.617...
0        # Push 0 again
 [       # Rotate a 2.718... back to the top of the stack
  -      # Subtract: 0-2.718... = -2.718...
   [     # Rotate the other 2.718... to the top
    -    # Subtract again: -2.718-2.718 = -5.436...
     -   # Subtract it: 60.617...--5.436 = 66.053...
0e-      # Push and subtract 1: 66.053...-1 = 65.053...

{  }     # Loop while the top of the stack is NOT 0:
 :       #  Duplicate the 65.053...
  @      #  Print it as character with this codepoint, where yup implicitly rounds
         #  decimals to their nearest integers when it needs an integer
\$\endgroup\$
1
\$\begingroup\$

GolfScript, 13 bytes

{"A".print}do

Try it online!

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

Rattle, 7 bytes

65|[,]0

Try it Online!

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\$

Thunno, \$ 5 \log_{256}(96) \approx \$ 4.12 bytes

['AZL

Attempt This Online!

Explanation

[       # while True:
   ZL   #  print with no newline:
 'A     #   "A"
\$\endgroup\$
1
\$\begingroup\$

Pip, 7 bytes

W1{O'A}

Attempt This Online!

Explanation

W1{   }  # while 1:
   O'A   #  print "A" without a trailing newline
\$\endgroup\$
1
\$\begingroup\$

Byte-based Instruction Jumping, 2 bytes

↓A

is a simply a placeholder for a non-printable ASCII character, so it takes a single byte of space. It evaluates to the following instructions:

mvr ... ... wrt cns ... ... mvl

It moves the instruction pointer to the byte on the right side of the current one (mvr), which is A, then writes it (wrt) to the console (cns) and moves back left (mvl). Now, the instruction pointer points to the first byte again, and executes the same instruction over and over forever.

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

JavaScript, 38 bytes

setInterval(()=>document.write("A"),4)
Wow, I did not expect JS would be that uncooperative! (setInterval(document.write,4,"A")) errors, but I guess that's screaming in a different way.

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

Racket, 25 bytes (10 brackets)

(let a()((print 'a)(a)))
\$\endgroup\$
1
1
\$\begingroup\$

Pascal, 51 bytes

This is a complete program according to ISO Standard 7185 "Standard Pascal". You may interpret it as a script, the standard does not prescribe or set restrictions to that.

PROGRAM A(OUTPUT);BEGIN WHILE 8=8 DO WRITE('A')END.
\$\endgroup\$
1
\$\begingroup\$

Swift, 36 35 bytes

while 1<2{print("A",terminator:"")}

Try it online!

  • Golfed 1 byte by reducing condition length
\$\endgroup\$
2
  • \$\begingroup\$ This is not valid; there should be no newlines present in the output. \$\endgroup\$ Commented Mar 21, 2023 at 18:15
  • 1
    \$\begingroup\$ @ConorO'Brien thank you for pointing that out! Fixed. \$\endgroup\$
    – user117104
    Commented Mar 21, 2023 at 18:26
1
\$\begingroup\$

Fortran, 50 49 bytes

program A
do
write(*,"(A)",advance="no")"A"
enddo
end

Try it online!

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

Commodore C64/VIC-20/C16/+4/C128 (using Kernal) 7 bytes

This is the assembled code at memory location 828 (some free RAM usually used as the Datasette buffer):

.033c a9 41 20 d2 ff d0 f9

Or in 6502 assembly:

* = 828
    lda #$41
    jsr $ffd2
    bne $033c

We can use a relative branch here (bne $033c) instead of a jump instruction, which saves one byte. The branch is conditional, but the condition is never set (it compares against the zero flag, and as the accumulator is set to a non-zero value, this condition is never met).

The lda #$41 loads the accumulator with the value 65, which is the letter A in PETSCII, and jsr $ffd2 calls to the CHROUT Kernal routine. This will translate the value on the accumulator register to a character code, and output to the default output device, which will be the screen in this instance. So the character A is outputted until the machine is reset.

Scream very loudly CodeGolf challenge, for the Commodore C64

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

Grass, 106 bytes

wwWWwWWWwvwWWwwwwWwwwwwwWWWWwwWWWWWwWwwwWWWWWWWwwWWWWWWWWwWWWWWWWWWwWwwwwWWWWWWWWWWWwwWwwvwWWwWWWWWwWWWwww

Try it online!

Grass is pretty difficult to follow, so I'll try to break things down as best as I can.

The first function, wwWWwWWWwv, takes in two parameters, a function and a character. It essentially just performs the given function on the character twice.

The second function creates the character A. Getting there is a little complicated, since the only character we initially have to work with is w. This means we have to call the primitive succession function 202 times. To accomplish this, we use the first function to recursively call succession several times. I've put what's currently at the top of the stack after each instruction.

w
WWwwww           (Succession Function x2)
Wwwwwww          (Last character +2)
WWWWww           (Succession Function x4)
WWWWWw           (Succession Function x8)
Wwww             (Last character +8)
WWWWWWWww        (Succession Function x16)
WWWWWWWWw        (Succession Function x32)
WWWWWWWWWw       (Succession Function x64)
Wwwww            (Last character +64)
WWWWWWWWWWWww    (Succession Function x128)
Www              (Last character +128)
v

The third and final function, wWWwWWWWWwWWWwww, is our main function, which calls the second function, prints its resulting A, and recursively calls itself.

\$\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_
    Commented Aug 6, 2021 at 13:13
1
\$\begingroup\$

uxn/vavara, 8 bytes

Compiled machine code:

00000000: 8041 8018 1740 fff8                      .A...@..

Source (in uxntal):

|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1

|0100 @on-reset ( -> )
    ( push a, the .Console/write port, output to device, then jump back to on-reset )
    LIT "A .Console/write DEO !on-reset

I think for this language the binary size should count since uxntal is basically just assembly for the uxn system

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

ByT, 29 bytes

main = 1 main 0 1 0 0 0 0 0 1

In this language the output is only printed after the program halts, so to print infinitely many As the program must halt with an infinite string in the stack. This program halts by trying to execute a 0 command that doesn't have enough arguments:

bar baz 0
    where
        foo = 1 main
        bar = foo 0
        baz = 0 0

In this situation baz is deleted and the final output is the string represented by bar, which is defined as: (using Haskell notation)

bar_str = "0" ++ foo_str
    where
        foo_str = main_str ++ "1"
        main_str = "10000010" ++ main_str ++ "1"

bar_str ends up being the bits 010000010100000101000001..., the same as AAA..., and this is printed to stdout.

This program turns out to be optimal. A main stack is required for compilation, so main = can't be golfed. An infinite string is also necessary and the only way of doing this is through recursion in the main stack, this string must also repeat some rotation of the bits 01000001, so they must be in the definition of main and therefore main 0 1 0 0 0 0 0 1 can't be golfed either. The only possible optimization would be removing the left most 1, but none of the eight possible 27 bit solutions work:

main = main 1 0 0 0 0 0 1 0     // prints nothing
main = main 0 1 0 0 0 0 0 1     // prints nothing
main = main 1 0 1 0 0 0 0 0     // prints nothing
main = main 0 1 0 1 0 0 0 0     // loops
main = main 0 0 1 0 1 0 0 0     // prints nothing
main = main 0 0 0 1 0 1 0 0     // prints nothing
main = main 0 0 0 0 1 0 1 0     // loops
main = main 0 0 0 0 0 1 0 1     // prints nothing
\$\endgroup\$
1
\$\begingroup\$

ELVM IR, 13 bytes

putc 65
jmp 0

Try it online!

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

Kotlin, 32 bytes

fun main(){while(0<1)print('A')}

Try it online!

\$\endgroup\$
1
3 4 5
6
7

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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