54
\$\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
  • 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
  • 3
    \$\begingroup\$ I'm surprised no one mentionned this helpful uncyclopedia page yet \$\endgroup\$
    – Oddrigue
    Mar 4, 2020 at 10:29

202 Answers 202

1 2
3
4 5
7
2
\$\begingroup\$

PHP, 16 14 bytes

for(;;)echo A;

Try it online!

  • -1 byte thx to @Kaddath!
\$\endgroup\$
4
  • 1
    \$\begingroup\$ You can save 1 byte with a for loop and echo ;) TIO \$\endgroup\$
    – Kaddath
    Mar 2, 2020 at 7:59
  • \$\begingroup\$ @Kaddath or 14 bytes with another tweak! TIO \$\endgroup\$
    – 640KB
    Mar 2, 2020 at 11:48
  • \$\begingroup\$ @IsmaelMiguel I don't think that's necessary, as command-line is allowed for PHP golf; documentation says: when running in command line mode, the default is 0 (unlimited) \$\endgroup\$
    – Kaddath
    Mar 2, 2020 at 12:06
  • \$\begingroup\$ @Kaddath You're right, I've deleted my comment. \$\endgroup\$ Mar 2, 2020 at 12:11
2
\$\begingroup\$

BASIC, 21 18 17 13 bytes

1?"A";
GOTO 1

Try it online!

Everyone's first program!

Credits:

  • -3 bytes thx to @ceilingcat
  • -1 byte thx to @S.S. Anne
  • -3 bytes more thx again to @ceilingcat!
\$\endgroup\$
5
  • \$\begingroup\$ You can't even get a BASIC link right. Disappointing... \$\endgroup\$
    – S.S. Anne
    Mar 2, 2020 at 1:26
  • \$\begingroup\$ 17 bytes. \$\endgroup\$
    – S.S. Anne
    Mar 2, 2020 at 1:29
  • \$\begingroup\$ Look around you. Look around you. Can you tell what we're looking for? \$\endgroup\$
    – JDL
    Mar 2, 2020 at 10:56
  • 1
    \$\begingroup\$ @JDL huh? I'm not following... \$\endgroup\$
    – 640KB
    Mar 2, 2020 at 12:27
  • \$\begingroup\$ @640KB maybe a reference to the BBC show \$\endgroup\$
    – ceilingcat
    Mar 5, 2020 at 1:25
2
\$\begingroup\$

Vim, 10 bytes

@Noodle9's answer of qqiA^[@q is a good start but is incorrect:

The call of macro-q is using any previous setting of macro-q. This only worked because, in testing, they had previously recorded macro-q to output A, so they were unwittingly relying on saved state.

You can see this by trying to change the A to a different letter, and the first time you test it you will still get 'A's. Or you can first clear macro-q with "qqq"

Here is a correct answer along the same lines:

qqiA^[@qq@q

qq            Record macro-q (the first time)
  i           Insert
   A          Letter 'A'
    ^[        Exit insert mode
      @q      Call macro-q
        qq    Stop recording
          @q  Call macro-q

Although this does require that nothing is in macro-q at the start, which I think is a fair assumption for code golf, that you are starting with a clean slate / fresh install, as opposed to random initialization state. If not, or if you want to test this and have macros set already, you would need to do:

qqqqqiA^[@qq@q

Where the initial 'qqq' will clear the macro-q.

Of course, all of this is much easier to read if you don't use 'q' for the macro. :)

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Does anyone ever use anything other than q for their macro? \$\endgroup\$
    – Neil
    Mar 5, 2020 at 13:25
  • \$\begingroup\$ Heh. I use 'w' sometimes, but that's because I have an odd keyboard. \$\endgroup\$ Mar 5, 2020 at 20:21
2
\$\begingroup\$

Python 2, 40 bytes

import sys
while 1:sys.stdout.write('A')

Try it online!

Python 2 prints with either a newline or a space separator but we can import the sys module then write to stdout to get round this.

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

Mumps/Caché, 8 bytes.

f ?'A';

Start an infinite loop (f) Print 'A' with no newline (?'A';)

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

R, 15 bytes

repeat cat('A')

Try it online!

Optimized thanks to @S.S. Anne

Perl 5 (cperl), 17 bytes

for(;;){print"A"}

Try it online!

Optimized 1 byte thanks to @S.S. Anne

Squirrel, 17 bytes

for(;;)print("A")

Try it online!

Optimized 1 byte thanks to @S.S. Anne

\$\endgroup\$
7
  • \$\begingroup\$ You should put these all in separate answers. \$\endgroup\$
    – S.S. Anne
    Feb 29, 2020 at 1:40
  • \$\begingroup\$ Ok :) I'll do it ! \$\endgroup\$
    – Bilel
    Feb 29, 2020 at 1:40
  • \$\begingroup\$ Perl 17-bytes Squirrel 21 (and watch out for captcha, it's been getting me a lot) \$\endgroup\$
    – S.S. Anne
    Feb 29, 2020 at 1:41
  • 2
    \$\begingroup\$ R 15 Squirrel 17 \$\endgroup\$
    – S.S. Anne
    Mar 2, 2020 at 1:33
  • 1
    \$\begingroup\$ For the R one, you don't need the braces; repeat cat("A") is fine. \$\endgroup\$
    – JDL
    Mar 2, 2020 at 10:56
2
\$\begingroup\$

Rail, 17 bytes

$'main'
@-[A]o[]@

- horizontal rail (a rail is required as entry from starting point $)

@ bumper to reverse travel direction

o prints characters between the brackets [ ]

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

MarioLANG, 45 bytes

+>+
+"+
+++
+++
++(
++-
+)[
+!<)+>.<
=#======

Try it online!

Mario falls down the first column, colecting 8 pluses. He then steps on the elevator and repeats the second and third column 8 times, colecting a total of 64 pluses in his second cell. After that, he adds another plus to that and starts running left and right, screaming "AAAA"

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

Hexadecimal Stacking Pseudo-Assembly Language, 30 bytes

000000200041400000130000010000

Try it online!

000000  label Start:
200041  input 0x41 (dec. 65, ASCII 'A')
400000  push that on stack 0
130000  print character from stack 0
010000  jump to Start:
\$\endgroup\$
2
\$\begingroup\$

Python 3, 25 22 bytes

Saved 3 bytes thanks to Jo King! :)

while 1:print(end='A')
\$\endgroup\$
3
  • \$\begingroup\$ That's a good idea actually. Thing is though it would be 26 bytes, and the question doesn't require efficiency. Sorry :( \$\endgroup\$ Mar 4, 2020 at 9:19
  • \$\begingroup\$ Ok, I'm lost. Could you give me your interpretation / solution? \$\endgroup\$ Mar 4, 2020 at 9:49
  • \$\begingroup\$ Edit: I just realised what you meant, sorry \$\endgroup\$ Mar 4, 2020 at 9:50
2
\$\begingroup\$

batch file 36 bytes

for /L %%n in (,,)do @ECHO|set/p="A"

batch console 35 bytes

This can be run directly in the windows cmd console.

for /L %n in (,,)do @ECHO|set/p="A"
  • -3 bytes and more thanks to @SomethingDark!
\$\endgroup\$
2
  • \$\begingroup\$ You can save three bytes by removing the 0s (although if you're doing this from a file instead of the command prompt, you need to add a byte by using %%n instead of %n). \$\endgroup\$ Mar 3, 2020 at 21:26
  • \$\begingroup\$ For the batch file version, you can use @%0 to loop, rather than relying on a for loop, and I think @set/p=A<nul works too. \$\endgroup\$
    – Neil
    Mar 5, 2020 at 13:24
2
\$\begingroup\$

PowerShell 27 25 bytes

for(1){Write-Host -n "A"}

Try it online!

-n parameter for Write-Host works as -NoNewline.

\$\endgroup\$
2
  • 3
    \$\begingroup\$ for() should work as well to save 3 bytes \$\endgroup\$
    – Veskah
    Mar 3, 2020 at 18:18
  • \$\begingroup\$ perhaps not heard. turn up volume: ıııııııııııııııııııııııııııııııııııııııı[]ııı \$\endgroup\$
    – mazzy
    Mar 5, 2020 at 4:18
2
\$\begingroup\$

Rabbit~, 5

A]:.[

Explanation:

A - store A to memory (not strictly used as A is already in memory, when loading the program. But the A is overwritten by a new A)
 ] - Start loop, read A as input
  :. - Print A character
    [ - Check current input, which is still A, carry on looping

Inverted brackets loops until input is not equal, doesn't terminate since input is always 'A'

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

Erlang (escript), 24 bytes

An operand-less function self-recursing, printing the string.

a()->io:fwrite("A"),a().

Try it online!

Explanation

a()->               % Define a niladic function.
io:fwrite("A")      % Print "A" to the console.
,a().               % After that, call itself again.
\$\endgroup\$
2
\$\begingroup\$

Cubix, 4 bytes

.'Ao

or

.o'A

Try it online!

. = starting point

'A = literal A

o = prints output

Since Cubix wraps around in a cube surface, it's an infinite loop.

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

Stax, 4 bytes

W'Ap

Run and debug it

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

!@#$%^&*()_+, 5 bytes

A(!@)

Try it online!

Very simple. Just push A, infinitely dup and print.

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

Stax, 3 bytes

W"A

Run and debug it

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

GORBITSA-ROM, 7 bytes

S\101TS\000B\000

in more readable form:

S65 T S0 B0

Explanation

S65          load 'A' into register
    T        output it
      S0 B0  jump to the beginning
\$\endgroup\$
2
\$\begingroup\$

Shakespeare Programming Language, 134 bytes

,.Ajax,.Puck,.Act I:.Scene I:.[Exeunt][Enter Ajax and Puck]
Ajax:You is the sum ofthe cube ofa big big cat a cat.Speak thy.Let usAct I.

Try it online!

(Newline added for readability.)

The ASCII code for A is 65, which is represented following this trick as \$65 = (2\cdot 2\cdot 1)^3 +1\$. Puck will say A indefinitely.

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

JavaScript, 25 34 bytes

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

Prints 'A' to the console indefinitely.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Unsure whether complies with the requirement “There shold be no newlines or seperators between the characters”. \$\endgroup\$
    – manatwork
    Jul 27, 2020 at 11:44
  • \$\begingroup\$ Sorry about that. Edited the answer. \$\endgroup\$
    – Razetime
    Jul 27, 2020 at 11:49
  • 3
    \$\begingroup\$ Yeah, but now with the exception of the unnecessary brackets, is identical with Joost K's solution posted more than 4 months ago (plus another one already deleted by its author). \$\endgroup\$
    – manatwork
    Jul 27, 2020 at 11:55
2
\$\begingroup\$

7, 7 6 5 bytes (19 15 13 characters)

1170363757403

Try it online!

Explanation

The main program pushes 77033|5|463 on the frame, and the last section, 463, runs. 4 swaps it with the previous section, a single 5, and 6 pacifies the 5 back into 5. 3 outputs the 5, specifying output format 5 ("US-TTY"), and deletes the 463 section which is now before it.

77033 is left on the frame, and it runs in a loop forever. 7703 creates an empty section and a section with 63, which is outputted by 3. 63 contains an anonymous command, so it can't be output directly. Instead, it is pacified and 7 is added before it, and the resulting string 703 is outputted. In output format 5, 7 is ignored and 03 corresponds to the character A, which is printed to STDOUT. The 77033 section hasn't been deleted (because we added an empty section to get deleted by 3 instead), so it runs again.

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

C++ (gcc), 38 bytes

#import<ios>
int A(){putchar(65)&A();}

Try it online!

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

Pyth, 4 bytes

#p\A
#     Infinite Loop
 p    Print with no newline
  \A  Single character string

Try it online!

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

Forth (gforth), 21 18 bytes

: f ." A"recurse ;

Try it online!

Although Forth typically tokenizes entirely by splitting on whitespace, as symbols and the like are allowed anywhere within a word, the word ." causes a string to be parsed up until a closing quote without also trying to parse that closing quote as part of a word.

I'm so unaccustomed to golfing in relatively ordinary languages that I forgot I could submit a named function!

Overflows the return stack quite quickly, and : f ." A"r> recurse ; doesn't take much longer to overflow the data stack, so without the assumption of infinite memory:

Forth (gforth), 25 22 20 bytes

[begin] ." A"[again]

Try it online!

-2 thanks to Bubbler

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Welcome to the league! You can use top-level looping words like this. \$\endgroup\$
    – Bubbler
    Nov 6, 2020 at 12:01
2
\$\begingroup\$

MAWP 0.1, 8 bytes

[94M5W;]

Explanation:

[          start of loop
94M5W      push 65 to stack ((9+4)*5)
;          print as ascii
]          end of loop
\$\endgroup\$
2
\$\begingroup\$

Add++, 10 bytes

x:"A"
Wx,o

Try it online!

First, we set x to A. A non-empty string is evaluated as true, so the While loop runs. o outputs the active variable, which is x, without a newline.

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

convey, 4 bytes

'A'}

Try it online!

An interesting (often annoying, but sometimes interesting) feature of convey is that string or number literals will output forever. So this outputs A constantly...

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