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 2 3
4
5
7
2
\$\begingroup\$

Factor, 19 bytes

[ "A"write t ] loop

Try it online!

loop looks at the top of the stack and performs another iteration if it finds t. This is 1 byte shorter than using forever.

\$\endgroup\$
2
\$\begingroup\$

Japt, 5 bytes

Assumes infinite memory.

ßOoau

Test it

ßOoau
ß         :Recursive call with (irrelevant) argument
 Oo       :  Output (returns undefined)
   au     :    "a" uppercased
\$\endgroup\$
2
\$\begingroup\$

Kotlin, 50 47 bytes

fun main(a:Array<String>){while(0<1)print("A")}

1.) Thanks to @Adam for pointing out the args naming

\$\endgroup\$
4
  • 1
    \$\begingroup\$ You can save 3 bytes by not naming your args 'args' :) \$\endgroup\$
    – Adam
    Commented Mar 3, 2020 at 15:05
  • 1
    \$\begingroup\$ You can just submit a bare lambda to save lots of bytes. \$\endgroup\$
    – snail_
    Commented Mar 17, 2020 at 8:00
  • \$\begingroup\$ You can even go down to 20 bytes if you compile it as a script then your code only becomes this: while(0<1)print("A") \$\endgroup\$
    – Yamin
    Commented May 16, 2021 at 3:36
  • \$\begingroup\$ You can actually remove the arguments \$\endgroup\$
    – Eric Xue
    Commented Jul 26, 2022 at 0:41
2
\$\begingroup\$

Octave / MATLAB, 21 20 bytes

1 byte off thanks to @Yelp!

while printf('A')end

Try it online!

Explanation

printf('A') prints 'A' to STDOUT and returns the number of printed characters, that is, 1. This number is used as condition for the while...end loop, which thus becomes an infinite loop.

\$\endgroup\$
2
  • \$\begingroup\$ Would while printf('A')end work? \$\endgroup\$
    – Yelp
    Commented Jun 28, 2021 at 17:38
  • \$\begingroup\$ @Yelp Yes, thank you! I didn't remember that Octave (unlike Matlab) has printf \$\endgroup\$
    – Luis Mendo
    Commented Jun 28, 2021 at 22:10
2
\$\begingroup\$

Written in Ark, 8 bytes

{~ !A }~

\$\endgroup\$
2
\$\begingroup\$

Minim, 10 Bytes

$<65.C=-1.

With whitespace and comments:

$< 65.  ; Print 65 as unicode 'A'
C = -1. ; Set program counter to -1 (advances to 0 afterwards)

GitHub Repository

\$\endgroup\$
2
  • \$\begingroup\$ Can you provide an interpreter for this language? \$\endgroup\$
    – emanresu A
    Commented Aug 14, 2021 at 0:41
  • \$\begingroup\$ @emanresuA I added the link to my GitHub Repo for the interpreter. \$\endgroup\$ Commented Aug 14, 2021 at 0:44
2
\$\begingroup\$

Swift, 35 bytes

while 1>0{print("A",terminator:"")}

Try It Online cuts it off after 128kiB of output, but this will run forever. Swift for loops are Python-like, not C-like, so those aren't any help here.

This is my first code golf for something other than Arduino.

\$\endgroup\$
2
\$\begingroup\$

Vim, 9 bytes

qqA<C-r>q<C-o>q<C-r>q

Uses the same Recursive Register Expansion trick as my Lolololololololololololol answer, inserting the unnamed register, which contains 'A' + the unnamed register. To see the output, you'll have to try it in Vim, and you may need to use Ctrl+C to stop the expansion if the terminal freezes.

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Perl 5 (ppencode), 35 33 bytes

print uc chr ord qw s abs while x

Try it online!

Previous

print uc chr ord qw s abs while exp

Try it online!

Alternatively:

print uc chr ord qw s abs while cos
\$\endgroup\$
2
\$\begingroup\$

Lexurgy, 17 bytes

a propagate:
*=>A

Forever replaces an empty string with A.

\$\endgroup\$
2
\$\begingroup\$

Piet, 15 Codels:

Original(5x3): Original Image

Scaled (x20):enter image description here

Operations in each loop:

push 8
dup
*
push 1
+
out(char) ;outputs 65 as 'A'

After each cycle, the index will flow through the white codel on the bottom left and repeat another cycle, running indefinitely.

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Rust, 17 bytes

loop{print!("A")}

Try it online!

Not much of a golfing language, but I love the loop keyword.

\$\endgroup\$
2
\$\begingroup\$

Emmental, 20 bytes

;#58#46#35#63#!#65#?

Try it online!

How?

;#58#46#35#63#!#65#?
;                     push ';' onto the stack
 #58#46#35#63         push ":.#?" onto the stack
             #        push NULL onto the stack
              !       pop NULL, ":.#?", and ';', and make NULL mean ":.#?"
               #65    push 'A' onto the stack
                  #   push NULL onto the stack
                   ?  execute NULL
:.#?
:    duplicate 'A'
 .   pop and print 'A'
  #  push NULL onto stack
   ? execute NULL
\$\endgroup\$
2
\$\begingroup\$

Flobnar, 7 bytes

g,_@
1A

Try it online!

It is most space-efficient to grab A from code than to try to evaluate from single-digit numbers.

@       Evaluate to west
_       If the other side (west) is 0, evaluate to east:
,         Print as char and return 0:
g         Grab code at (1,1) which is 'A' (so A is printed)
1
_       The return value is 0, so evaluate to east,
        which is start of the program again (which also acts as <)
        so it is an infinite loop printing 'A' repeatedly
\$\endgroup\$
2
\$\begingroup\$

Trilangle, 4 bytes

This version has constant memory usage.

"A,o

Try it on the online interpreter!

Push an A, print it and pop it. For lack of an explicit exit instruction @, this loops infinitely by default.

Trilangle, 3 bytes

This version's memory usage grows without bound.

"Ao
\$\endgroup\$
2
\$\begingroup\$

><> (Fish), 4 bytes

5d*o

Try it

or

"A"o
\$\endgroup\$
1
\$\begingroup\$

dc, 9

[65Pdx]dx

Explanation

[     ]   # Push a macro to the stack
 65       # Push the number 65 to the stack
   P      # Pop and print ASCII char 65 (i.e. "A") with no newline
    d     # Duplicate the macro
     x    # Pop and execute the macro at the top-of-stack (tail recursion)
       d  # Duplicate the macro
        x # Pop and execute the macro at the top-of-stack

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ I'd love to know the reason for the downvote, so I can improve my answer. \$\endgroup\$ Commented Mar 4, 2020 at 16:06
1
\$\begingroup\$

C++ (gcc), 49 bytes

#import<iostream>
int A(){for(;;)std::cout<<'A';}

Uses C++ I/O.

Try it online!

C++ (gcc), 41 bytes

#import<ios>
int A(){for(;;)printf("A");}

Uses C I/O.

Try it online!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ I don’t know c++ well but it appears that replacing your include with #include<cstdio> and your cout with printf loses 4 bytes. I tried to paste my revision, but found myself incapable on mobile… \$\endgroup\$
    – cole
    Commented Mar 1, 2020 at 20:29
  • 1
    \$\begingroup\$ int A(){for(;;)__builtin_printf("A");} is shorter; you can remove the import \$\endgroup\$ Commented Mar 6, 2020 at 3:43
1
\$\begingroup\$

VisiCalc, 3 bytes

You need an extra newline to enter the instruction. It's a modification of this solution.

/-A

The trailing newline is significant.

Explanation

/   Start a command:
 -  Replicate forever
  A The target for replication is the / character
Extra newline to enter the instruction

You end up with a cell with an infinite number of A's.
However, the current cell can only show a finite amount
of A's because cells are trunctuated based on their lengths.
```
\$\endgroup\$
1
\$\begingroup\$

MathGolf, 6 bytes

1É'Aq↑

Try it online.

Or

æ'A_q▲

Try it online.

Explanation:

1       # Push a 1
     ↑  # While true without popping,
 É      # using the following 3 commands:
  'A   '#  Push an "A"
    q   #  Pop and print it without trailing newline

     ▲  # Do while true with pop,
æ       # using the following 4 commands:
 'A    '#  Push an "A"
   _    #  Duplicate this "A"
    q   #  Pop and print it without trailing newline
\$\endgroup\$
1
\$\begingroup\$

Julia 1.0, 17 bytes

f()=print('A')f()

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ -1 byte using a Symbol instead of a Char Try it online! \$\endgroup\$
    – MarcMush
    Commented May 11, 2021 at 10:59
1
\$\begingroup\$

Bash, 14 bytes

yes A|tr -cd A

will very quickly output A's.

\$\endgroup\$
1
  • \$\begingroup\$ Alternate 14-byte solution: yes A|tr -d \\n \$\endgroup\$
    – nph
    Commented Jun 27, 2020 at 14:25
1
\$\begingroup\$

Rust, 17 bytes

loop{print!("A")}

Try it online!

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

Lua, 27 bytes

while 1 do io.write("A")end

Try it online!

\$\endgroup\$
3
  • 1
    \$\begingroup\$ I believe this is suppossed to be an uppercase "A". \$\endgroup\$
    – ouflak
    Commented Mar 3, 2020 at 8:25
  • \$\begingroup\$ You are absolutely right, thanks I fixed it. \$\endgroup\$
    – Lycea
    Commented Mar 3, 2020 at 10:30
  • \$\begingroup\$ -1 byte Try it online! \$\endgroup\$
    – emirps
    Commented Mar 15, 2023 at 13:02
1
\$\begingroup\$

Red - 16 bytes

forever[prin 'A]
\$\endgroup\$
1
\$\begingroup\$

perl -l101 -E, 12 bytes

{print;redo}
\$\endgroup\$
6
  • 1
    \$\begingroup\$ I can't seem to get this to work properly. It stalls but I don't get any output. Are there any more relevant details here? \$\endgroup\$
    – Wheat Wizard
    Commented Mar 3, 2020 at 23:52
  • \$\begingroup\$ Really clever program - it encodes the A character under the flags! \$\endgroup\$
    – user92069
    Commented Mar 4, 2020 at 0:29
  • \$\begingroup\$ @PostRockGarfHunter Did you use the command line parameters exactly as given? perl -l101 -E '{print;redo}' The command line parameters are important. \$\endgroup\$
    – Tuna salad
    Commented Mar 4, 2020 at 1:53
  • \$\begingroup\$ @Tunasalad I believe you need to add the length of the command line flags to your score: codegolf.meta.stackexchange.com/questions/273/… \$\endgroup\$
    – milk
    Commented Mar 4, 2020 at 2:43
  • \$\begingroup\$ @milk That answer is outdated. We no longer count flags. \$\endgroup\$
    – Wheat Wizard
    Commented Mar 4, 2020 at 4:38
1
\$\begingroup\$

4, 15 bytes

3.6006580050094

3. start of code

6 assigns to cell 00 the value 65

8 starts the loop, keeps running while cell 00 is not zero.

5 prints ASCII character of the cell 00

9 closes the loop

4 end of code

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

Kenbark-1 (first personal computer) 6/7 bytes

002:
024 X 
004 PC
234 200 Print A from X
343 004 jump back to begin of the program

Register X is on Address 002 (oct) Then we set program Counter (address 003) to 004 for starting code. Move value from X (024='A') to output register what is set of lights on device front (Address 200 oct). And unconditional jump back to address 004.

User will see steady light, but in reality computer still output A

I'm not sure how to count bytes since that 002: is needed to tell computer what part of memory we need to fill.

Try it by yourself: http://www.neocomputer.org/kenbak/kenbak1-JS.html

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

C# (Visual C# Interactive Compiler), 21 18 bytes

for(;;)Write('A');

Try it online!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Why not for(;;)? \$\endgroup\$ Commented Mar 6, 2020 at 7:35
  • \$\begingroup\$ @mypronounismonicareinstate Thanks, I forgot about it \$\endgroup\$ Commented Mar 9, 2020 at 11:25
1
\$\begingroup\$

JavaScript (Node.js), 33 32 bytes

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

Try it online!

-1 byte thanks to Maria Miller

\$\endgroup\$
1
  • 1
    \$\begingroup\$ You can replace while(1) with for(;;) and -1 byte \$\endgroup\$
    – naffetS
    Commented Mar 10, 2020 at 18:37
1 2 3
4
5
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.