title: Output your Score!

text:
# Question
Title: Output your Score!
**Challenge:**

The concept is simple enough: write a full program to output its own code golf score!

Output should only be the byte count of your program and a trailing  `bytes`.

**BUT WAIT**..... there is one restriction:

* Your source code can not include any of the digits from your byte count
* So if your score is `186 bytes`, your program can not contain the characters `1` , `6` , or `8`

**Example Output:**

```
315 bytes
27 Bytes
49 BYTES

```

**Additional Rules:**

* Unnecessary characters, spaces, and newlines are forbidden in the source code, however trailing spaces and newlines are perfectly acceptable in output
* There should be a single space between the number and `bytes` in the output
* Letters are case insensitive
* No self inspection or reading the source code
* standard loopholes are disallowed
* this is , so

**Shortest code in bytes wins!**

# Answer
# JavaScript, 19 bytes

Octal was invented to serve two purposes:

* setting file permissions in Linux
* answering this challenge

```
alert(023+' bytes')
```

Try it online!
> 59 votes

# Answer
# Perl 5, 16 bytes

There are many other ways to get `16` but this one is mine

```
say afpbytes^PPP

```

Try it online!
> 39 votes

# Answer
# , 23 characters, 9 bytes

```
54340045141332401057403

```

Try it online!

This is a fairly hard challenge in a language that consists entirely of digits, but I managed it…

This is just 9 bytes in 7's encoding. (Strictly speaking, it's 8⅜ bytes (23 × ⅜ − ¼ because the final two trailing 1 bits can be omitted), but for the first time, PPCG's requirement to round up to a whole number of bytes is actually an advantage because it means that the extra trailing 1 bits are necessary and thus not banned by the question.) A reversible hex dump:

```
00000000: b1c0 2530 b6a0 22f8 1f                   ..%0.."..

```

The main challenge of writing this program in 7 was golfing it to under 10 bytes (as writing 7 without using `0` or `1` is pretty hard.) This uses the same structure as the standard "Hello world" program:

```
5434004514133240105**7**403
5434004514133240105      commands 0-5 append literals to data space
                   **7**     start a new section of data space
                    403  another literal appended to data space
                         {implicit: eval the last section as commands}
                    **4**    swap 1st and 2nd sections with an empty section between
                     **6**   reconstruct the commands that would create the 1st section
                      **3**  output (+ some other effects we don't care about)

```

In other words, we start by creating two sections of the data space; we have two literals, each of which pushes a sequence of commands there. The second section (they're pushed stack-style so first push = last pop) is a fairly arbitrary sequence of commands but is pushed using the command sequence `5434004514133240105` (thus producing the data sequence **`5434664574733246765`**; when discussing 7 in text, I normally use normal font for a command that pushes a literal, and bold for the corresponding resulting literal). The first section is pushed using the command sequence `403`, producing **`463`**. Then the first section is copied back to the program (an implicit behaviour of 7).

The **`463`** is now composed of (bold) commands that do something immediately, rather than (non-bold) commands that just push literals. **`4`** rearranges the sections to get our "string literal" into the first section. Then **`0`** does the operation that 7 is most known for: taking a section of data space, and reconstructing the command sequence that's most likely to have created it. In the case where the original command sequence was all `0`-`5`, this is 100% accurate (unsurprisingly, as those commands purely push data and thus leave obvious evidence of what they did), and so we get our original sequence `5434004514133240105` back. Finally, **`3`** prints it.

So the remaining thing to look at here is the encoding of the string. This has its own domain-specific language:

```
5434004514133240105
5                    change encoding: 6 bits per character
 43                  select character set: digits and common symbols
   40                '9'
     04              space
       51            select character set: uppercase letters
         4133240105  'B' 'Y' 'T' 'E' 'S'

```

(There's no "select character set: lowercase letters" in the "digits and common symbols" character set – you have to go via a different character set first – so I needed to use uppercase to golf this short enough to fit underneath the effective 10-byte limit.)
> 36 votes

# Answer
# Canvas, 8 bytes

```
８ bytes＋

```

Try it here!

A more interesting 20 byte solution:

```
bytecount.innerText＃

```

Try it here!
> 22 votes

# Answer
# brainfuck, 53 BYTES

```
+[[<+>->->++>----<<<]>-]>-.--.<<<+.<.<.-----.>+++.<-.

```

Try it online!

Another submission with capitalised `bytes`. Found with the help of the excellent BF-crunch helper by primo.
> 14 votes

# Answer
# PHP, 14 bytes

```
<?=7*2?> bytes

```
> 12 votes

# Answer
# Python 3, ~~25~~ ~~24~~ 18 bytes

```
print(6*3,'bytes')

```

Try it online!
> 10 votes

# Answer
# Stax, 5 bytes

```
╗↑╞ô╝

```

Run and debug it

Unpacked, it looks like this. Packed source mode makes this kind of trivial and uninteresting.

```
5p     print 5 with no line break
`5l@   print the compressed string " bytes"

```

If you don't want to use packed source mode, `6^p`5l@` works for 7 bytes.
> 10 votes

# Answer
# PHP older than 7.2, 13 bytes

Assumes default settings (E\_NOTICE warnings disabled) and PHP version older than 7.2.

Needs to be decoded with `xxd -r`

```
00000000: 3c3f 3d7e cecc df9d 868b 9a8c 3b         <?=~........;

```

Or if you prefer Base64

```
PD89fs7M352Gi5qMOw==

```

Try it online!
> 9 votes

# Answer
# Pyramid Scheme, ~~477~~ 440 BytEs

```
     ^   ^       ^   ^       ^   ^
    ^-  / \     ^-  / \     ^-  / \
   / \ /out\   / \ /out\   / \ /out\
  /out\-----^ /out\-----^ /out\-----^
 ^-----^   / \-----^   / \-----^   / \
 -^   / \ /chr\   / \ /chr\   / \ /chr\
  -^ /chr\-----^ /chr\-----^ /chr\-----^
  /*\-----^   / \-----^   / \-----^   / \
 ^---^   / \ /66 \   / \ /116\   / \ /115\
/8\ / \ /32 \-----  /121\-----  /69 \-----
---/55 \-----       -----       -----
   -----

```

Try it online!

Outputs `440 BytEs` by multiplying 8 by 55.
> 8 votes

# Answer
# Keg, 6 bytes

```
bytes

```

Uses an unprintable character at the beginning to push 6 to the stack. Then when it gets printed at the end, a space is automatically added after the 6 due to it being an integer.

Try it Online!
> 8 votes

# Answer
# , 16 bytes

```
cat(4*4,"bytes")

```

Try it online!
> 7 votes

# Answer
# dc, ~~14~~ 11 bytes

```
[ bytes]Bnn

```

Try it online!

-3 bytes by `@Cows quack`
> 6 votes

# Answer
# 05AB1E, 6 bytes

```
₂¤“ÿ¡Ï

```

Try it online!

---

```
₂      # [26]        | Pushes 26 (many other alternatives).
 ¤     # [2, 6]      | Split out tail.
  “ÿ¡Ï # ['6 bytes'] | ÿ = "Interpolate top of stack.", ¡Ï = "bytes" (compressed)

```

---

Alternatives for `₂¤` include: `5>`, `₁¤`,
> 6 votes

# Answer
# Bash, 21 bytes

"Read your own source code" is clearly not the winner here, but no one else submitted one, so what the heck.

```
echo `wc -c<$0` bytes

```

Try it online!
> 6 votes

# Answer
# Brain-Flak, ~~100 BYTES~~ 80 bYTES

```
((((((()()()))[]{})))((({}){})(((({}){}))<([]([](([][][])([{}]()({{}}))))[])>)))

```

Try it online!

Outputs the `bytes` part in reverse title case. Does away with the `(<>)` abuse to pad the stack height and instead reuses those elements to add up to 83 for the final push, as well as contributing to pushing the `80`  part.

Initially, this pushes `3 8 8 32 32` to the main stack while pushing `8 16 32` to the "third" stack (this is used to produce `80`  (`8+16+32,16+32,32`)). Then inside that we push the `bytes` part inside a `< >`. Here we use the stack height (`5`) to get the differences between the elements (`9 5 15 -14`) before finally summing the stack to produce `83` (`S`).
> 6 votes

# Answer
# PHP + HTML, 16 bytes

```
16 bytes

```

Yes, this is getting pretty close to loophole abuse, but I felt this needed to be posted. And the use of PHP means that this answer technically *is* written in a Turing-complete programming language. Of course, any other similar HTML templating language would work just as well.

Live demo (without PHP):

```
16 bytes
```
> 6 votes

# Answer
# Whitespace, 112 bytes

Just because nobody's done it yet:

```

```

Try it online!

Prints " BYTES" in caps, since uppercase letters have shorter binary ASCII codes. The commands in the program, in my own made up visible notation, are:

```
Push 112
PrintNum
Push 0
Push 0x53
Push 0x45
Push 0x54
Push 0x59
Push 0x42
Push 0x20
Label _
PrintChr
Dup
JumpZ S
Jump _
Label S
End

```
> 6 votes

# Answer
# Haskell, 26 bytes

```
main=putStr$"\50\54 bytes"

```

Try it online!

---

### 29 bytes

```
main=putStr$pred<$>"3:!czuft"

```

Try it online!
> 5 votes

# Answer
# Octave, 22 bytes

```
disp([50 50 ' bytes'])

```

Try it online!
> 5 votes

# Answer
# Applescript, 15 bytes

Yes, I’m going there.

```
9+6&”bytes”

```
> 5 votes

# Answer
# Retina, 15 bytes

```

 bytes
*>w`..+

```

This program counts the number of substrings with at least two characters in the string " bytes", and then prints this count and the string itself.

Try it online!
> 5 votes

# Answer
# Poetic, 277 bytes

```
for the A.I. system i did, i tried to put in humans
i know i am one of those
i am trying human testing for cyber-enabled virtual brains
a for-profit company rakes in massive loads of cash educating interns,
& then force-feeding things to all the interns until we earn a diploma

```

Outputs `277 bytes`.

Try it online!

Poetic is an esolang I made in 2018 for a class project. It's basically brainfuck with word-lengths instead of symbols.

This was a fun program to write, although I'm not entirely sure I've fulfilled the "no unnecessary characters" requirement. If my answer needs to be amended, let me know!
> 5 votes

# Answer
# Forth (gforth), ~~14~~ 13 bytes

```
$d . ." bytes

```

Try it online!
> 4 votes

# Answer
# Java 5 or 6, 44 bytes (full program)

```
enum A{A;{System.out.print(0x2C+" bytes");}}

```

No TIO-link, because Java 5/6 is old.. In Java 5/6 it was possible to have an enum with code instead of the mandatory `main`-method, making it shorter for full program challenges.

Also errors with `java.lang.NoSuchMethodError: main\nException in thread "main"` in STDERR after printing to STDOUT, which is fine according to the meta (but if the challenge would have disallowed additional errors to STDERR, `System.exit(0);` can be added (and the octal numbers has to be updated) to prevent the error.

Suggested by *@OlivierGrégoire* (and his relevant Java tip).

# Java 8+, 74 bytes (full program)

```
interface M{static void main(String[]a){System.out.print(0112+" bytes");}}

```

Try it online.

# Java 8+, ~~16~~ 15 bytes (lambda function)

```
v->0xF+" bytes"

```

-1 byte thanks to *@OliverGégoire*.

Try it online.
> 4 votes

# Answer
# C, ~~33~~ 32 bytes

```
main(){printf("%d bytes",040);}

```

There is a trailing newline, which is not "unnecessary" since the C standard demands it. Try it online here.

Thanks to NieDzejkob for golfing 1 byte.

Alternative with the same bytecount, thanks to ErikF:

```
main(){printf("%d bytes",' ');}

```

Try it online here.
> 4 votes

# Answer
# Octave, 23 bytes

```
printf('%i bytes',9+14)

```

Try it online!

And this:

```
disp(['','67$f}xiw'-4])

```

Try it online!
> 4 votes

# Answer
# APL (Dyalog Unicode), 12 bytes

Full program which implicitly prints to STDOUT.

```
'bytes',⍨3×4

```

Try it online!

`,⍨` is appends the string to the result of the multiplication. APL's default display of mixed-type data puts a space between a number and subsequent text.
> 4 votes

# Answer
# MATL, 13 bytes

```
'57$f}xiw'4-c

```

Try it online!

This pushes the string '57$f}xiw' and subtracts `4`, to get `13 bytes`. This is converted to characters using `c`.
> 4 votes

# Answer
# Petit Computer BASIC, 11 bytes

```
?9+2,"bytes

```

Using a comma in a print statement will move the cursor over to the next multiple of the current tab size. In SmileBASIC, that is 4 by default, so this would output `11 bytes` (2 spaces) but PTC BASIC used 3 instead, so the output has the correct spacing.
> 4 votes

# Answer
# FerNANDo, 79 bytes

```
3 3
1
2 2
0 1 3 3 1 2 2 3
0 1 3 3 2 1 0 2
0 1 3 0 0 1 0 1
0 3 3 1 0 0 3 1
1 1
1

```

Try it online!
> 4 votes

# Answer
## Hexagony, ~~26~~ 22 Bytes

```
B{3'/bs.<t>;ey;:!$@P0/

```

*-4 Bytes @Jo King*

Try it online!

---

More Readable:
```
   B { 3 '
  / b s . <
 t > ; e y ;
: ! $ @ P 0 /
 . . . . . .
  . . . . .
   . . . .

```

Reuses every semicolon twice similar to this answer.
> 4 votes

# Answer
# Red, 43 bytes

```
print[to-integer 8.6 * length? b: "bytes"b]

```
> 4 votes

# Answer
# Bash, ~~20~~ ~~18~~ 17 bytes

```
echo $[8+9] bytes

```

Try it online!

-2 bytes thanks to @manatwork.
-1 byte thanks to @boboquack.
> 3 votes

# Answer
## \>\<\>, 13 bytes

```
#o<" bytes"nd

```

Try it online!
> 3 votes

# Answer
# JavaScript, ~~16~~ 15 bytes

```
x=>0xf+' bytes'

```
> 3 votes

# Answer
## Batch, 32 bytes

```
@@echo %COMSPEC:~-10,-010% bytes

```

`COMSPEC` is usually `%WINDIR%\system32\cmd.exe` so I extract the substring from 10 to 8 characters from the end. Old 16-byte self-referencing version:

```
@echo %~z0 bytes

```

Fortunately the byte count wasn't a multiple of 10.
> 3 votes

# Answer
## 7Zip - ~~90~~ 14 bytes

Hex dump:

```
00 75 0d 08 c0 00 0d 08 03 00 00 03 04 1d

```

To use:

save into a source file, named anything.

run the compiler from the command line: `7z e [source name]`
> 3 votes

# Answer
# Excel VBA, 10 bytes

An anonymous VBE immediate window function that takes no input and outputs to the vbe immediate window.

```
?2*5"bytes

```

### Output

```
10 bytes

```
> 3 votes

# Answer
# C++ (GCC), 51 bytes

*Thanks to @ceilingcat!*

```
#import<iostream>
main(){std::cout<<063<<" bytes";}

```

Try it online!

# C++ (GCC), 56 bytes

```
#import<iostream>
main(){std::cout<<(int)'8'<<" bytes";}

```

Try it online!

**More portable version (60 bytes):**

```
#import<iostream>
int main(){std::cout<<(int)'<'<<" bytes";}

```

`#import` is not standard C++, but should work at least with GCC, Clang, and MSVC.

Try it online!

**Standard compliant version (61 bytes):**

```
#include<iostream>
int main(){std::cout<<(int)'='<<" bytes";}

```

Try it online!
> 3 votes

# Answer
# TI-Basic (TI-84 Plus CE with OS 5.2+), 14 bytes

```
toString(9+5)+" BYTES

```

`toString(` is a two-byte token, all other characters used are one-byte tokens.

`toString(` can be replaced with `eval(` for the same output and score.

Explanation:

* `toString(9+5)` Returns the string `"14"`
* `+" BYTES` Adds the string `" BYTES"`, to get `"14 BYTES"`
* TI-Basic implicitly returns/prints the last item evaluated, so `13 BYTES` is output.
> 3 votes

# Answer
# Jstx, 4 bytes

```
♦─]P

```

Try it online!
> 3 votes

# Answer
# m4, 15 bytes

As in the m4 POSIX macro processor.

```
eval(8+7) bytes

```
> 3 votes

# Answer
# Vim, 12 10 bytes

```
i9*<C-o><C-a>* bytes
```
> 3 votes

# Answer
# Mathematica frontend, 18 bytes (maybe 10?)

```
Row@{2*9," bytes"}

```

Thanks to @ovs

## A naughty way ... as I don't know whether this counts (10)

```
2" bytes"5

```

Well it depends on how you define *space*.

## Wolfram Language (Mathematica), solution w/o frontend (30)

```
Print[ToString[5*6]<>" bytes"]

```

Try it online!
> 3 votes

# Answer
# MathGolf, 9 bytes

```
G½ "bytes

```

Try it online!

## Explanation

Quite simple really

```
G            Push 18
 ½           Halve the result, giving 9
             Push a space character
   "bytes    Push "bytes"

```
> 3 votes

# Answer
# Python 3, 18 bytes

```
print(9*2,'bytes')

```

Try it online!
> 3 votes

# Answer
# Python 2, 17 bytes

```
print 9+8,'bytes'

```

Output: `17 bytes`
> 3 votes

# Answer
# C# (Mono C# Shell), 27 bytes

```
Console.Write(3*9+" bytes")

```

Try it online!
> 3 votes

# Answer
# Perl 5 \+ `-Mfeature+say`, 14 bytes

Relies on a generated program, so TIO link is to Bash which generates the program from `xxd` output. Uses `-Mfeature+say` instead of `-M5.10.0` although I don't think it matters that much...

```
say~"ÎËß"

```

Try it online!
> 3 votes

# Answer
# Brain-Flak, 90 bYTES

```
((((((<>))))[])[]([]((((([][][]))))([{}]()([]({}{}){}{}<>)))))(([][])[()]((([]{}))({}{})))

```

Try it online!

It took a while but I got us down to double digits.

I stole a technique of pushing a bunch of zeros in order to abuse `[]` from JoKing's answer. However I have modified it a bit.

Instead of pushing zeros I just push whatever is convenient (which does happen to include zeros). This is ok since JoKing gets rid of them with a loop that doesn't pick up zeros (which is reversing the stack), I use `<>` to switch to the other stack.

Other than that shared trick out answers are quite divergent.
> 3 votes

# Answer
# GolfScript, 10 bytes

```
n)" bytes"

```

Try it online!

`n` is a variable that represents `\n`, `)` separates the last char from `n` and parses it to an integer. The ascii value of `\n` is 10.
> 3 votes

# Answer
# Templates Considered Harmful, 30 bytes

```
St<51,48,' ','B',89,84,69,'S'>

```

Try it online!

This should be the best possible score. Every character here can be represented by a 2 byte ascii (ex. 66) value, or a 3 byte char literal (ex. 'B'). 28 is the theoretical minimum representing every character as ascii, but it is blocked by space being value 32. 29 is also blocked by Y and E. 30 works.
> 3 votes

# Answer
# Risky, 32 bytes

```
*+}*!*1!**/*1*1++*{*1*1!}*}*1+1+*+1**+1!***+{*{+***+1*1!***+!*/

```

Try it online!
> 3 votes

# Answer
# Vyxal , ~~7~~ 6 bytes

<sup>-1 bytes thanks to Bubbler</sup>

```
kṄt`¨ƈ

```

## Explanation

```
kṄ                - Push "4096"
  t               - Get the final item (6)
   `¨ƈ            - Push "bytes"
<flag>            - Join by spaces ("6 bytes")
<implicit>        - Print it.

```

Try it Online!
> 3 votes

# Answer
# Pyth, 10 bytes

```
+T" bytes"

```

Try it here

If you don't mind separating with a newline instead of a space, you can get it down to 8 bytes with

```
y4"bytes

```
> 2 votes

# Answer
# Jelly, 7 bytes

```
“¢>¶ŒD»

```

Try it online!

Compressed strings.
> 2 votes

# Answer
# CJam, ~~10~~ 10 bytes

```
Ao" bytes"

```

Try it online!
> 2 votes

# Answer
# MATL, 12 bytes

```
6EV' bytes'h

```

Try it online!

Pushes `6`, doubles with `E`, converts that to a string with `V`, and `h`orzcats it with the string `' bytes'` to get the proper spacing. Implicit output takes care of the rest.
> 2 votes

# Answer
# , 19 bytes

```
echo' bytes',~":_bj

```

Try it online!
> 2 votes

# Answer
# C# (.NET Core), 65 bytes

```
class P{static void Main(){System.Console.Write(0x41+" bytes");}}

```

Try it online!
> 2 votes

# Answer
# SNOBOL4 (CSNOBOL4), 27 bytes

```
	OUTPUT =3 * 9 ' bytes'
END

```

Try it online!

prints with a trailing newline.
> 2 votes

# Answer
# Japt, 8 bytes

```
#+` ßs

```

char-code 8 concatenated with " bytes" compressed.

Try it online!
> 2 votes

# Answer
## Excel (Immediate Window), 12 bytes

```
?3*4&"bytes"

```

This solution assumes that leading space is allowed.
Below the one without leading space in output (14 bytes):

```
?2*7&&" bytes"

```

It's the result of suspicious behaviour of the concatenate operator `&`. When only one, it surrounds the number with spaces; however two consecutive ones strip the spaces. Weird.
> 2 votes

# Answer
# PowerShell, 14 bytes

```
"$(2*7) bytes"

```

Try it online!

Ho-hum. Uses an inline code block `$(...)` to put `14` into the string before leaving it on the pipeline. Output is implicit.
> 2 votes

# Answer
# Ruby, 18 bytes

```
puts"#{6*3} bytes"

```

Try it online!
> 2 votes

# Answer
# brainfuck, 95 bytes

```
+[--------->+<]>.----.--[--->++<]>--.[->+++<]>++.[--->+<]>+++.-----.+++[->+++<]>.[--->+<]>----.

```

Try it online!

97 bytes:

```
>-[++>+[+<]>]>+.--.>++++[->++++++++<]>.[->+++<]>++.[--->+<]>+++.-----.+++[->+++<]>.[--->+<]>----.

```
> 2 votes

# Answer
# Gol\>\<\>, 11 bytes

```
bn"setyb "H

```

Try it online!

### How it works

```
bn"setyb "H
b            push number 11
 n           pop and print as integer
  "setyb "   push " bytes" in reverse order
          H  print the stack content as chars, then halt

```
> 2 votes

# Answer
# Google Sheets, 12 bytes

An anonymous worksheet function that takes no input and outputs to the calling cell

```
=3*4&" bytes

```
> 2 votes

# Answer
# MSSQL, ~~26~~ 24 bytes

```
print str(8*3) +' bytes'

```
> 2 votes

# Answer
# F#, ~~24~~ 23 bytes

I hope this counts. Never code golfed before

```
printfn "%i bytes" 0x17

```

Just switched ~~24 to octal~~ 23 to hex

Try it online!
> 2 votes

# Answer
# Husk, 8 bytes

```
+sD4¨₆Ẏ¿

```

Try it online!

### Explanation

```
+sD4¨₆Ẏ¿
    ¨₆Ẏ¿  Compressed string of " bytes"
  D4        Multiply 4 by 2
 s          Convert to string
+         Concatenate the strings

```
> 2 votes

# Answer
## Windows Command Line, 20 bytes

```
set/a4*5&echo  bytes

```

Run Windows Command Prompt (cmd.exe), type the command and hit Enter.
> 2 votes

# Answer
# SQL, 18 bytes

```
SELECT 2*9,'bytes'

```
> 2 votes

# Answer
# Swift 4, ~~19~~ 18 bytes

<sup>*Saved 1 byte thanks to Jo King.*</sup>

```
print(9*2,"bytes")

```

Try it online!
> 2 votes

# Answer
## ArnoldC, 216 Bytes

Try it online!

```
IT'S SHOWTIME
    HEY CHRISTMAS TREE i
    YOU SET US UP 4
    GET TO THE CHOPPER i
        HERE IS MY INVITATION i
        YOU'RE FIRED 54
    ENOUGH TALK
    TALK TO THE HAND i
    TALK TO THE HAND "BYTES"
YOU HAVE BEEN TERMINATED

```

**Output**

```
216
BYTES

```

Well, i took too long with my **php** answer, i had to try this.

As far as i read, i can't write without a line break or concatenate an integer with a string :(
> 2 votes

# Answer
# Backhand, 11 bytes

```
"" sbbeOytH

```

Try it online!

Non-linear pointer progression makes for weird looking programs. Outputs `11 bytes`.

The orde: of commands is such:

```
"  s  e  t      Start string literal to push letters
                Bounce and go left
     b  y       Finish pushing " bytes"
                Bounce and go right
 "  b  O  H   Push 11 to print and then halt and output the stack

```
> 2 votes

# Answer
## C#, ~~68~~ ~~65~~ 64 bytes

```
class P{static void Main(){System.Console.Write(8*8+" bytes");}}

```

Try it online!
> 2 votes

# Answer
# 33, 14 bytes

Technically non-competing, as I made the language after this challenge was posted.

```
2c7xo" bytes"p

```

Pretty simple. Multiplies 2 and 7.
> 2 votes

# Answer
# Runic Enchantments, 10 bytes

```
` ā`XESa@

```

Try it online!

Huh, I thumbed this one up and never answered it.

`ā` encodes the value 257 (still shorter than any other method) which gets multiplied by 10 and converted to a word via a dictionary. `2570` happens to be `bytes`. `a` encodes `10` (`b`-`f` encode `11` through `15`) and gets around the "no digits" restriction. And conveniently enough, the rest of the program is 9 bytes.

Doesn't end up being shorter than `" bytes"a@` (also 10 bytes), but oh well.
> 2 votes

# Answer
## `d`, 7 bytes

```
♣êæ█☺₧K

```

## Explanation

Unpacked:

```
7 bytes"

```
> 2 votes

# Answer
# RProgN 2, 10 bytes

```
°' Bytes'.

```

# Explination

```
°           # Push 10 to the stack
 ' Bytes'   # Push the literal string " Bytes" to the stack
         .  # Concatenate. Implicit print.

```

Try it online!
> 2 votes

# Answer
## Javascript, 15 bytes

`j=>0xf+' bytes'`

Seems like the obvious answer.

Alternative:

`j=>9+6+' bytes'`
> 2 votes

# Answer
# Golfscript, 12 bytes

```
6 6+" bytes"

```

Try it online!
> 2 votes

# Answer
# RAMDISP, ~~133~~ 26 bytes

~~There's room for improvement.~~

~~```
[P[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]][*[[[[]]]]][+[[[]]]][S[; bytes]]]]

```~~

~~i honestly don't even remember how i did this, i attached a debugger, and found it it calculates 3 * 37 + 2.~~

```
[P[5[*5][+1][S[; bytes]]]]

```

26 = 5\*5+1
> 2 votes

# Answer
# PICO-8, 25 bytes

```
print(ord("」").." bytes")

```

`ord()` gets the index of a character, and  is character 25 in P8SCII.
> 2 votes

# Answer
# Haskell, 34 bytes

```
main=putStr$show(0x1D+5)++" bytes"

```

Try it online!
> 2 votes

# Answer
# \>\<\>, 13 bytes

```
dn'setyb '>o<

```

Try it online!
> 2 votes

# Answer
# Vyxal , 5 bytes

```
4›`¨∞

```

Try it Online!

## Explanation :

```
4     # push 4
 ›    # increment
  `¨∞ # push "Bytes"
      # flag `ṡ` => join with space
      # implicit output

```
> 2 votes

# Answer
# dc, 14 bytes

```
7d+n[ bytes]p

```

Double it
> 2 votes

# Answer
# Python 2, ~~18~~ 17 bytes

```
print 8+9,'bytes'

```

-1 byte thanks to *@Wondercricket*.

Try it online.
> 1 votes

# Answer
# SOGL V0.12, 8 bytes

```
┌`m39Σ³‘

```

Try it Here!
> 1 votes

# Answer
# Pari/GP, 18 bytes

```
print(2*9" bytes")

```

Try it online!
> 1 votes

# Answer
# SmileBASIC, 12 bytes

```
?3*4;" bytes

```

(Probably works in a bunch of other BASIC dialects, too)

Alternatives:

```
?&HC;" bytes
?9+3;" bytes

```
> 1 votes

# Answer
# jamal, 14 characters

```
{@* 2 7} bytes

```

Sample run:

```
bash-4.4$ perl jamal.pl ownsize.jam
14 bytes

```
> 1 votes

# Answer
# Fortran (GFortran), 24 bytes

```
PRINT*,11+13,'BYTES'
END

```

Try it online!

Outputs "24 BYTES" with some leading spaces, because, you know, it's Fortran... you can't tell him to do something and expect that he will do exactly as you said, specially if it involves strings :)
> 1 votes

# Answer
# Befunge-98 (FBBI), 12 bytes

```
"c.4k,@setyb

```

Try it online!

Thank you Jo King and Mistah Figgins for -3 bytes.
> 1 votes

# Answer
# TeX, 16 bytes

```
^^q^^v bytes\bye

```
> 1 votes

# Answer
# Ruby, 15 bytes

```
p"#{0xf} bytes"

```

Try it online!
> 1 votes

# Answer
# Foo, 13 bytes

```
&9+4$i" bytes

```

Try it online!

## Explanation

```
&9+4$i" bytes
&9              push 9
  +4            add 4 (13)
    $i          output as integer
      " bytes   print out " bytes"

```

## 14 bytes

```
@20&$h" bytes"

```

Same general idea, but (ab)uses hexadecimal printing.
> 1 votes

# Answer
# Pyth, 11 bytes

```
+hT" bytes"

```

Try it online!
> 1 votes

# Answer
# Rust, 34 bytes

```
fn main(){print!("{} bytes",17*2)}

```

Try it online!
> 1 votes

# Answer
# C# (Visual C# Interactive Compiler), 20 bytes

```
Write(11+9+" bytes")

```

Try it online!
> 1 votes

# Answer
# Excel, 13 bytes

```
=6+7&" bytes"

```

Output: `13 bytes`

Nothing fancy. It's different from the other Excel answers as those are both based in VBA. This formula version is longer.
> 1 votes

# Answer
# C, 50 49 46 28 bytes

```
m(){printf("%i bytes",' ');}

```

we need to tell the linker about our custom entry point and make sure stdio.h is included:

```
cc -o x x.c -e _m -include stdio.h

```

Notice, that the character in the printf statement is should not be a space but the ascii character for 28 (FS) in decimal. I am not able to edit the answer and add this.
> 1 votes

# Answer
# T-SQL, 32 bytes

```
print char(51)+char(50)+' bytes'

```

Best I could come up with.
> 1 votes

# Answer
# Javascript,26 bytes

```
console.log(78/3+" bytes")

```

Try it online!
> 1 votes

# Answer
# Octave, 42 bytes

I figured I'd try a more interesting approach that's Octave-specific (and only works on some platforms).

```
printf('%i bytes',printf('%c',8+~(10:51)))

```

Note: This doesn't work on TIO or Octave-online.net, but it does work on Octave 4.2.0 on my laptop.

### Explanation:

`printf('%i bytes',... )` specifies that we will print a string starting with an integer `%i` followed by the characters `' bytes'`. The second part of the first `printf`-function call is another call to `printf('%c',...)`. When `printf` is called with an output argument, it returns the number of characters in the output string, as well as the string. The second part of the second `printf` call is `8+~(10:51)`. This is a shorter way to write `[8, 8, 8 ...]` 42 times. **8** is the ASCII-value of the backspace. The string to be printed is therefore 42 backspaces. This doesn't show when typing it in the terminal, so we'll get `42 bytes` without a trailing newline:
> 1 votes

# Answer
# MySQL, 28 bytes

```
SELECT CONCAT(7*4,' bytes');

```
> 1 votes

# Answer
# Tcl, 23 bytes

```
puts [scan  %c]\ bytes

```

Try it online!

---

# Tcl, 23 bytes

```
puts [expr 19+4]\ bytes

```

Try it online!
> 1 votes

# Answer
# Ruby, 16 bytes

```
p "#{9+7} bytes"

```

Try it online!
> 1 votes

# Answer
# Attache, 19 bytes

```
Print&$bytes!STN!$t

```

Try it online!

## Explanation

```
Print&$bytes!STN!$t
Print       !          print
     &$bytes           (with "bytes" as a right argument)
             STN!      convert string to number...
                 $t    "t" (corresponds to 19)

```

In sane syntax, this is: `Print[STN["t"], "bytes"]`, which joins the arguments by spaces.
> 1 votes

# Answer
# Pepe, 74 bytes

```
rEeEeeEeEereEEreeeEeeeeereeEEeeeEereeEEEEeeEreeEEEeEeereeEEeeEeEreeEEEeeEE

```

Try it online!

It's a boring answer, `rEeEeeEeEereEE` pushes 74 into stack r and outputs the number, and the rest of the code prints `bytes`
> 1 votes

# Answer
# Python (REPL), 16 bytes

```
'%d bytes'%(8*2)

```

### Output :

```
16 bytes

```
> 1 votes

# Answer
# vim, 12 bytes

```
a9 bytes<ESC>03<C-A>

```

`<ESC>` is 0x1b. `<C-A>` is 0x01

Try it online!
> 1 votes

# Answer
# MBASIC, 17 bytes

```
6 PRINT 8+9"bytes

```

MBASIC requires line numbers; "6" doesn't appear in the output either. Turns out that the trailing quote is optional.

Output:

```
RUN
 17 bytes
Ok

```
> 1 votes

# Answer
# Cubix, 23 bytes

```
@"!w"SETYB"uUo<S;O'$.;

```

Try it online!

Cubified:

```
    @ "
    ! w
" S E T Y B " u
U o < S ; O  '
    $ .
    ; .

```

Watch it run

Failrly simple pushes SETYB onto the stack, pushes character 23 (ETB) and outputs as an integer. Push 32 (space) onto the stack then start outputting chars and popping until stack is empty.
> 1 votes

# Answer
# LOLCODE, 66 bytes

Just because it's funny

```
HAI 1.2,VISIBLE SMOOSH PRODUKT OF 2 AN 33 AN " bytes" MKAY,KTHXBYE

```

## Output

`66 bytes`
> 1 votes

# Answer
# Pascal (FPC), 29 bytes

```
begin write($1D,' bytes')end.

```

Try it online!

`$1D` is a hexadecimal constant. I'm glad Pascal has something shorter than other languages!
> 1 votes

# Answer
# k (oK), 16 bytes

Try it online!

```
($:4*4)," bytes"

```

String result of 4\*4 and concatenate
> 1 votes

# Answer
# Chevron, 12 bytes

```
^n<<3*4
>^n

```

This is a fairly new language of my own creation - prototype interpreter, documentation, and example programs can be found at https://github.com/superloach/chevron.

## Explanation:

* `^n<<3*4` \- calculate 3\*4, store as n
* `>^n` \- output n
* nothing else - implicit exit
> 1 votes

# Answer
# Deadfish~, 59 bytes

```
iisioiiiioii{ii}icii{iii}iic{ii}iiicdddddc{d}dddddc{i}iiiic

```

Try it online!
> 1 votes

# Answer
# C++, 52 bytes

```
[]{std::string a="41 bytes";a[0]++;a[1]++;return a;}

```

Try it online!

*facepalm* is it even competable? it just barely wins against BF! but still, no 5s and 2s in the code.
> 1 votes

# Answer
# C, 31 bytes

```
main(){printf("%d bytes",'');}

```

Try It Online!

The unprintable character is the *unit separator* which value is 31.
> 1 votes

# Answer
# naz, ~~48~~ 44 bytes

```
2a2a2o2s2m8m1o2m2a1o9a9a5a1o5s1o9s6s1o9a5a1o

```

**Explanation**

```
2a2a2o   # Output "4" twice
2s2m8m1o # Output a space
2m2a1o   # Output "B"
9a9a5a1o # Output "Y"
5s1o     # Output "T"
9s6s1o   # Output "E"
9a5a1o   # Output "S"

```

Original 48-byte solution: `2a2a1o2a2a1o2m2m1o3m2a1o9a9a5a1o5s1o9s6s1o9a5a1o`
> 1 votes

# Answer
# Zsh, 16 bytes

```
<<<$[8*2]\ bytes

```

Try it online!

Heavily inspired by the Bash answer. `<<<` usually saves two bytes, but we lose one to escape a space.
> 1 votes

# Answer
# x86-16 ASM, IBM PC DOS, ~~36~~ 29 bytes

**Listing:**

```
        START:
B0 1D       MOV  AL, SZ         ; get program size
D4 0A       AAM                 ; BCD convert byte (AH=ones, AL=tens)
86 E0       XCHG AH, AL         ; endian convert (AH=tens, AL=ones)
50          PUSH AX             ; save AH = 9
3030        ADD  AX, '00'       ; ASCII convert
BF 0114     MOV  DI, OFFSET S   ; output string in DI
8B D7       MOV  DX, DI         ; and output string in DX
AB          STOSW               ; write digits to beginning of string
58          POP  AX             ; restore AH = 9 (DOS write string function)
CD 21       INT  21H            ; write to console
C3          RET                 ; return to DOS
        S   DB '   bytes$'      ; output string buffer
        SZ  EQU LOW $-START     ; subtract starting address from ending address

```

Calculates the difference between the `START` memory address and the ending memory address. Then writes that value as decimal ASCII followed by the string ' bytes'.

There are no `0x02`, `0x09`, ASCII `'2'` (`0x32`) or ASCII `'9'` (`0x39`) in the code.

**Output:**
> 1 votes

# Answer
# International Phonetic Esoteric Language, 13 bytes

```
" bytes"94suo

```

Explanation:

```
" bytes"      (push the string)
        94s   (push 13 by adding)
           uo (print twice)

```

Alternative (also 13 bytes):

```
" bytes"{D}uo (D == 13 base 36)

```
> 1 votes

# Answer
# Pxem, 11 bytes.

* Filename: `.n bytes.p`
    + Escaped: `\013.n bytes.p`
* Content: empty.

Try it online!
> 1 votes

# Answer
# BRASCA, 13 bytes

```
Ln`setyb `[o]

```

Try it!

## Explanation

```
Ln              - Output 13 as number
  `setyb `      - Push "bytes "
          [o]   - Output the rest of the stack

```
> 1 votes

# Answer
# Nim, 17 bytes

```
echo 8+9," bytes"

```

Try it online!
> 1 votes

# Answer
# PEP8 Assembly, 50 bytes

```
STRO 4,d
STOP
.WORD 13616
.ASCII " BYTES"
.END

```

13616 is "50" in ASCII

A programming language made as an introduction to assembly and low-level concepts. Not sure I've seen it used here before, so might be a first?
> 1 votes

# Answer
# Python 3, 34 bytes

```
print(f'{chr(51)}{chr(52)} bytes')

```

Try it online!
> 1 votes

# Answer
# TI-Basic, 27 BYTES

```
Text(0,0,3*3²," BYTES

```

outputs on the graph. `Text(` allows to chain things to output, which `Output(` or `Disp` don't allow

there is probably room for improvement with one of those

* 27 in 2 or 3 bytes is possible but useless (`3^3`, )
* 26 in 3 bytes
* 25 in 2 bytes ( not valid)
* 24 in 1 byte ??

This solution should work on all TI-83 and 84. See also the 14 byte solution for the TI-84+ CE.
> 1 votes

# Answer
# Befunge-93, 19 bytes

```
82*3+."setyb">:#,_@

```

Outputs `19 bytes`.

Try it online!

Version with no numbers:

```
"D""/"-."setyb">:#,_@

```

Outputs `21 bytes`.

Try it online!
> 1 votes

# Answer
# Python 3, ~~22~~ 19 bytes

```
print(22-3,'bytes')

```

Try it online!

Thanks to @twentysix for -3 bytes
> 1 votes

# Answer
# GeoGebra, ~~13~~ 12 bytes

*Thanks Lince Assassino for -1 bytes*

```
6+6+" bytes"

```

Pasting that into the GeoGebra calculator and pressing `Enter` gives the string `12 bytes`.
> 1 votes

# Answer
# Behaviour, 12 bytes

```
6+6+" bytes"

```

The output is implicit, but if we need explicit print, here's one for 13 bytes:

```
@6+7+" bytes"

```
> 1 votes

# Answer
# Aussie++, 35 bytes

```
G'DAY MATE!
GIMME ""+70/2+" bytes";

```

Tested in commit 9522366.

---

This was more annoying to golf than I thought it would be. At first I tried this (33 bytes):

```
G'DAY MATE!
GIMME 11+22+" bytes";

```

But for some bizarre reason, this prints out `bytes33`, not `33 bytes` (see this github issue). So then I tried this (36 bytes):

```
G'DAY MATE!
GIMME ""+12+24+" bytes";

```

But that printed out `1224 bytes`. I thought I could be clever and tried this (35 bytes):

```
G'DAY MATE!
GIMME ""+41-6+" bytes";

```

Only to be given the error `THOSE AREN'T FUCKIN NUMBERS MATE!`. It became apparent that I had to use parens if I wanted to use addition or subtraction.

However, parens aren't necessary for multiplication. I tried multiplication, but I reached an impasse: using `17*2` made it be 35 bytes but print 34, using `4*9` made it be 34 bytes but print 36, etc. I could use `(4*9)` to be 36 and print 36, but then I'd be breaking the rule on unnecessary characters (I think).

Only after considering using `(9+28)` for 37 bytes did the idea of division come to mind.
> 1 votes

# Answer
# Lexurgy, 15 bytes

```
a:
*=>15\ bytes

```
> 1 votes

# Answer
# Minecraft Command Blocks, 198 bytes

A series of five command blocks with these commands:

```
scoreboard objectives add s dummy
scoreboard players set s s 33
scoreboard players set b s 6
scoreboard players operation s s *= b s
tellraw @a [{"score":{"name":"s","objective":"s"}},{"text":" bytes"}]

```

Pretty simple, it calculates 6 * 33 and prints the answer +  `bytes`. I got lucky and didn't have to adjust the length of anything.
> 1 votes

# Answer
# Microscript II, 13 bytes

`7s6+p" bytes"`

Pretty trivial, just adds 7 and 6 to get 13, and uses implicit output for the trailing  `bytes`.
> 1 votes

# Answer
# Knight, 17 bytes

```
O++''-8~9' bytes'

```

Try it online!

My second attempt at a second entry for the August 2022 language of the month event.

The original solution is left here for posterity

```
OUTPUT++''%60 36' bytes'

```
> 1 votes

# Answer
# Headascii, 55 BYTES

```
++++[]]]][]^^]]+++++PPDP++]]P^]+++++++P-----P(D+++P<-P!

```

Try it here, code will have to be pasted in and executed as shown below:

```
erun("++++[]]]][]^^]]+++++PPDP++]]P^]+++++++P-----P(D+++P<-P!")

```

Outputs `55 BYTES`

Code breakdown:

```
++++[]]]][]^^]]+++++PPDP++]]P^]+++++++P-----P(D+++P<-P! full program
++++[]]]][                                              save 16 to R2
          ]^^                                           save 32 to R1
             ]]+++++PP                                  append "55" to string register
                      DP                                append " " to string register
                        ++]]P                           append "B" to string register
                             ^                          save 66 to R1
                              ]+++++++P                 append "Y" to string register
                                       -----P           append "T" to string register
                                             (          store 84 in R3
                                              D+++P     append "E" to string register
                                                   <-P  append "S" to string register
                                                      ! print string register

```

This breakdown isn't great but the basic idea is that `[^(` store to registers and `]D<` return values from registers, and treat the rest like brainfuck basically :P
> 1 votes

# Answer
# RProgN 2, 12 bytes

```
34*" bytes"+

```

Try it online!
> 1 votes

# Answer
# JavaScript, 20 bytes

```
alert(5*4+" bytes");

```
> 0 votes

# Answer
# Jotlin, 17 bytes

```
P("${8+9} bytes")

```

Uses the println builtin
> 0 votes

# Answer
# Attache, 18 bytes

```
Print[!4-6,$bytes]

```

Try it online!

This is simply printing `!4-6` (which is `factorial(4) - 6`) followed by `bytes`.
> 0 votes

# Answer
# Groovy, 22 bytes

```
{print"${0x16} bytes"}

```

Try it online!
> 0 votes

# Answer
# AWK, ~~19~~ 14 bytes

```
$0=2*7" bytes"

```

Try it online!
> 0 votes

# Answer
# Pyt, 35 bytes

```
2⁵1⁺ᴇ⁻⁻1ᴇ⁺²2ᴇ4²+9⁺²⁺1ᴇ⁺²6-áƇǰ8Ḟ1+⇹ǰ

```

Try it online!

Explanation:

```
2⁵         Push 32
1⁺ᴇ⁻⁻      Push 98
1ᴇ⁺²       Push 121
2ᴇ4²+      Push 116
9⁺²⁺       Push 101
1ᴇ⁺²6-     Push 115
á          Convert stack to array, and push the array onto the stack
Ƈ          Cast to characters ([" ","b","y","t","e","s"])
ǰ          Join the elements of the array (" bytes")
8Ḟ1+       Push 35
⇹          Swap the top two elements on the stack
ǰ          Concatenate the stack as a string ("35 bytes")
           Implicit print

```
> 0 votes

# Answer
# Batch, 31 bytes

```
@set /a r=29+2
@echo %r% bytes

```
> 0 votes

# Answer
# Swift, 22 bytes

```
print("\(18+4) bytes")

```

Try it online!
> 0 votes

# Answer
# K4, ~~18~~ 15 bytes

**Solution:**

```
($6+9)," bytes"

```

**Example:**

```
q)k)($6+9)," bytes"
"15 bytes"

```

**Explanation:**

Evaluated right-to-left, don't think I can get lower than 15 this way:

```
($6+9)," bytes" / the solution
      ," bytes" / join " bytes" with...
(    )          / do together
  6+9           / 6+9 = 15
 $              / cast to string

```

**Alternative:**

Another **15 byte** solution, has potential to be golfed if anyone can make `"41"` in 4 chars or `"31"` in 3 chars:

```
|"setyb ",$49+2

```
> 0 votes

# Answer
# Pip, 10 bytes

```
t." bytes"

```

Try it online!

Conveniently, there's a preset variable for the number 10.
> 0 votes

# Answer
# Yabasic, 15 bytes

An anonymous answer that takes no input and outputs to STDOUT.

```
?7+8;
?" bytes"

```

Try it online!
> 0 votes

# Answer
# uBASIC, 14 bytes

An anonymous answer.

```
0?2*7;" bytes"

```

Try it online!
> 0 votes

# Answer
# MY-BASIC, 18 bytes

An anonymous MY-BASIC answer that outputs to STDOUT.

```
Print 9+9," bytes"

```

Try it online!
> 0 votes

# Answer
# Visual Basic .NET (Mono), 66 bytes

A declared `Sub`routine that takes no input and outputs to the console.

```
Module M
Sub Main
Console.Write(3*22 &" bytes")
End Sub
End Module

```

Try it online!
> 0 votes

# Answer
# Red, 19 bytes

```
prin[22 - 3 'bytes]

```

Try it online!
> 0 votes

# Answer
# jshell, 12 bytes

```
9+3+" bytes"

```

I don't think it's on TIO.run despite having an article on Wikipedia.
> 0 votes

# Answer
# Neim, 10 bytes

```
μ( bytes)B

```

`μ` represents `10`.

Try it online!
> 0 votes

# Answer
# Bash, 17 Bytes

```
echo $[8+9] bytes

```

output:

```
17 bytes

```
> 0 votes

# Answer
# Vim, 13 Bytes

```
i<Ctrl-r>=7+6<Enter> bytes

```
> 0 votes

# Answer
# FALSE, 11 bytes

```
'\u000B." bytes"

```

`\u000B` should be replaced by the corresponding character.
> 0 votes

# Answer
# Go, 66 64 bytes

```
package main;import"fmt";func main(){fmt.Printf("%d bytes",'@')}

```
> 0 votes

# Answer
# Haxe, 20 bytes

```
trace(4*5+' bytes');

```

Try it online!
> 0 votes

# Answer
# C# (.NET Core), 16 bytes

```
n=>8*2+" bytes";

```

Try it online!

---

# 39 bytes

```
n=>System.Console.Write(~-40+" bytes");

```

Not sure whether returning the output from a function is valid, if not, here's a 39 byte solution.

Try it online!
> 0 votes

# Answer
# Hoon, 23 bytes

```
(runt 1^0vcpi " bytes")

```

`(runt [p q] "tape")` prepends a byte sequence `q` to a string `p` number of times. `p^q` is sugar for `[p q]`, and `0vXXX` is base32 (`@uv`) encoding for the byte string `'23'`.
> 0 votes

# Answer
# Pyke, 9 bytes

```
75 02 94 0A 09 58 EF 64 4A

```

Try it here!

```
u 02 94 0A 09      - integer list, length 2 ([2570, 9])
             X     - splat(^)
              .o   - lookup 2570 in dictionary (bytes)
                dJ - join by " "

```
> 0 votes

# Answer
# , 13 bytes

```
a20 bytes<esc>^7<C-x>

```

`<esc>` is `\x1B` and `<C-x>` is `\x18`.

Try it online!
> 0 votes

# Answer
# Ly, 14 bytes

```
72*u" bytes"&o

```

Try it online!

I tried a solution based on Ly's quine, but it quickly turned out to cost more bytes than it saved.
> 0 votes

# Answer
# Clojure, 24 bytes

```
(println(+ 17 7)"bytes")

```

Try it online!
> 0 votes

# Answer
# Emojicode, 46 bytes

```
38 8 bytes

```

Try it online!

I wanted to add my own answer to this question, but seeing as y’all took all the GOOD languages, I had to pick one of the weird ones
> 0 votes

# Answer
# Lua, 21 bytes

```
print(3*7 ..' bytes')

```

The space before .. (string concatenation operator) is required or the parser sees 7.. as a malformed number.
> 0 votes

# Answer
# Aceto, ~~16~~ 15 bytes

```
es7+
t"8p
ybp
"

```

We first push `" bytes"`, then `78+` (15) and then print both.

*edit: Fixed counting final newline character* *edit2: Saved 1 byte thanks to Jo King*
> 0 votes

# Answer
# Excel, 13 bytes

```
=4+9&" bytes"

```

Using `CONCATENATE` for 28 bytes:

```
=CONCATENATE(4*6+4," bytes")

```
> 0 votes

# Answer
## Go, 46 Bytes

```
package main;func main(){print(38+8," bytes")}

```
> 0 votes

# Answer
# LOWER, 93 bytes

```
ₔ₉₃ₔₓ₃₂ₔₓ₉₈ₔₓ₁₂₁ₔₓ₁₁₆ₔₓ₁₀₁ₔₓ₁₁₅

```

Try it online!

This is all Unicode characters, so no `9`s or `3`s here.
> 0 votes

# Answer
# JavaScript (Node.js), 22 bytes

```
alert(`${8+14} bytes`)

```
> 0 votes

# Answer
# Make, 96 bytes

```
d=$1 $1 $1 $1 $1 $1 $1 $1
all:
	@echo $(words $(call d,x x x x x x x) $(call d,x x x x x)) bytes

```

Try it online!
> 0 votes

# Answer
# C (gcc), 32 bytes

```
main(){printf("%d bytes",8*4);}

```

Nothing crazy here.
> 0 votes

# Answer
# Commodore 64 - 74 tokenized and BASIC bytes

Assuming by score in bytes, you mean tokens and bytes used by the BASIC interpreter, this works:

```
0 def fn b(x) = 38911-(fre(x)-2^16*(fre(x)<x)): print fnb(.);"bytes

```

There is a bug in the FRE() function on the Commodore 64 as it assumes maximum size of BASIC is 32K, or 32768 bytes.

### Commodore VIC-20 (unexpanded) - 29 tonkenized and BASIC bytes

```
0?(60*60-17)-fre(.)"bytes

```
> 0 votes

# Answer
# Zsh, 16 bytes

```
<<<$[##␐]\ bytes
```

Attempt This Online!

should be a literal `0x10` byte, but that doesn't show up in SE markdown.

---

## Zsh `-BCDEFGHIJ`, 13 bytes

```
<<<$#-\ bytes
```

Attempt This Online!

Cheating.
> 0 votes

# Answer
# Thunno, 14 bytes

```
7 2*J" bytes"+

```

Attempt This Online!

#### Explanation

```
7 2*             # Push 7 * 2 (14)
    J            # Convert to string
     " bytes"    # Push the string " bytes"
             +   # Concatenate
                 # Implicit output

```
> 0 votes

# Answer
# Malbolge, 106 bytes

```
D'`_ML"n<YkFEVwwe@PsON;:ml[kG4ECe#z@x,_^)\[Zvotm3qSi/gfed*hgfH%]baZ_^W{UZSRWVUNrR4PINGLEiIBG@dDCB$@?>=<5YF

```

Try it online!

Created with zb3 malbolge tools
> 0 votes

# Answer
# 05AB1E, 15 bytes

```
30 2/ò" bytes"J

```

Try it online!
> 0 votes

# Answer
# TypeScript's type system, 24 bytes

```
type F=`${0o30} bytes`;;

```

Try it at the TS playground

TIL TypeScript has octal literal types. Two dead bytes because `0o26` has a `2` in it.

# TypeScript's type system, ~~65~~ 55 bytes

```
type Z=[1,1,1,1,1]["length"]
type F=`${Z}${Z} bytes`;;;

```

Try it at the TS playground

3 dead bytes there, in order to get both digits the same.
> 0 votes

# Answer
## Pascal, 48 Bytes

Pascal according to ISO standard 10206 “Extended Pascal” allows you to specify `integer` literals up to a base of 36.

```
program p(output);begin write(7#66,' Bytes')end.

```

```
program p(output);begin write(9#53,' Bytes')end.

```

See also the FreePascal submission.
> 0 votes

# Answer
# YASEPL, 16 bytes

```
=a$**^~>" bytes"

```

# ibe, 28 bytes

```
dheoslresluuslopslotslupslor

```
> 0 votes

# Answer
# J-uby, 28 bytes

I know more succinct solutions are possible but this one amused me.

```
:join&:succ*[?1,?7," byter"]

```

Attempt This Online!
> 0 votes

---
Tags: code-golf, restricted-source, self-referential
---


title: Print random integers until 0

text:
# Question
Title: Print random integers until 0
You are to write a program which generates random integers between \\$0\\$ and \\$99\\$ inclusive, outputting each integer in turn, until \\$0\\$ is generated. You may choose which single-order random distribution (uniform, binomial, Poisson etc.) you use so long as each integer has a non-zero chance of being generated and is chosen independently. The output should always end with `0`. As each integer must be chosen independently, the output cannot be some permutation of the integers \\$\\{0, 1, 2, ..., 99\\}\\$ trimmed to end with \\$0\\$.

You may follow another method to accomplish the same task, so long as the result is identical to the described method here (for example: you may generate a number \\$K\\$ geometrically distributed with parameter \\$\frac 1 {99}\\$, then output \\$K\\$ independent numbers with a uniform distribution on the set \\$\\{1, 2, ..., 99\\}\\$, then output a \\$0\\$).

The integers may be separated by any non-digit, non-empty separator (e.g. newlines, spaces etc.), and may be output in any consistent base. You may output in any convenient method or format.

This is so the shortest code in bytes wins.

# Answer
# Scratch 3.0, 9 blocks/76 bytes

As SB Syntax:

```
define
set[N v]to(1
repeat until<(N)=(0
set[N v]to(pick random(0)to(99
say(N

```

Try it on Scratch

It just wouldn't be right if I didn't golf this in scratch. This is a function that achieves the desired result

## Explained

```
define                             // Create a function with no name (not a lambda)
set[N v]to(1                       // Initalise the variable we will use to generate random numbers with
                                   // If we didn't set it to 1, the next loop wouldn't start, as it would see that N = 0.
repeat until<(N)=(0                // Pretty self-explanatory
set[N v]to(pick random(0)to(99     // Also pretty self-explanatory. But putting this here means we don't have to include two calls to this block: we've essentially created a post-test loop instead of a pre-test loop
say(N                              // Output the randomly generated number and repeat

```
> 20 votes

# Answer
# Python 3, 58 bytes

```
from random import*
print(*iter(lambda:randint(0,99),0),0)

```

Try it online!
> 15 votes

# Answer
# , 25 bytes

```
c(sample(99,rexp(1),T),0)

```

Try it online!

p(0) at each iteration is (e-1)/e.
p(each other number) at each iteration is (1/e)\*(1/99).

Obviously this choice of random distribution gives a rather unsatisfying-looking output (since most of the runs are rather short). So this link uses the same approach, but changes p(0) to roughly 0.01 to illustrate some longer runs...

**What's going on?**

```
            rexp(1)         # First determine where the '0' will occur:
                            # We generate a single random number using
                            # an exponential distribution with a
                            # rate parameter equal to 1
                            # (so the chance of any value x is e^-x).
c(                    ,0)   # Now place '0' at the subsequent position,
  sample(99,rexp(1),T)      # and fill all the previous positions with
                            # numbers sampled from 1 to 99,
                            # with replacement (specified by the 'T' for TRUE).

```
> 14 votes

# Answer
# Ruby, ~~19~~ 18 bytes

-1 byte thanks to Dingus!

```
loop{1/p(rand~99)}

```

Try it online!

`rand~99` generates a random integer below `abs(~99)=abs(-100)=100`, `p` prints it to the output and returns the integer as a function and `1/x` fails for `x==0`, stopping the program.
> 13 votes

# Answer
# Random Brainfuck, ~~67~~ ~~66~~ ~~65~~ 49 bytes

```
+[>>-[>++<-----]>--<?[>->+<[>]>[<+>-]<<[<]>-]>>.]

```

Try it online!

Finally found a use for this silly variant.

Assumes wrapping cells and that the tape will never overflow (which would be statistically improbable).

Basically, Random Brainfuck is just normal Brainfuck, except it adds the `?` opcode which reads a byte from `/dev/urandom`.

All I have to do is modulo 100.

I move forward 6 bytes each iteration.

Outputs random **bytes** to stdout.

```
+                             (1) 0 0 0 0
[ do
    # advance tape two places for sentinel
    >>                        0 (0) 0 0
    # set 100
    # https://esolangs.org/wiki/Brainfuck_constants#100
    -[>++<-----]>--           0 0 0 (100) 0
    # Read random byte
    <?                        0 (rng) 100 0
    # mod 100
    # https://esolangs.org/wiki/Brainfuck_algorithms#Modulus_algorithm
    [>->+<[>]>[<+>-]<<[<]>-]  0 (0) * rng % 100
    # move left and print
    >>                        0 0 * (rng % 100)
    .                         print
] while rng % 100 != zero     note: start

```

The equivalent C algorithm:

```
void print_random(void)
{
    uint8_t rng;
    do {
        rng = randbyte() % 100;
        putchar(rng);
    } while (rng != 0);
}

```
> 13 votes

# Answer
# , ~~30~~ 29 bytes

```
while(print(sample(0:99,1)))T

```

Try it online!

`print` returns its argument invisibly, so this will choose an integer from 0-99 uniformly at random until a `0` is printed, because `0` is falsey in R.

Uses the "do-`while`" tip.

Thanks to Robin Ryder for saving a byte.
> 12 votes

# Answer
# Python 3.8, ~~52~~ 50 bytes

-2 bytes inspired by EasyasPi's answer.

Produces some integers with probability \\$\frac 2 {256}\\$ and some with probability \\$\frac 3 {256}\\$ in each iteration.

```
import os
while id:print(id:=os.urandom(1)[0]%100)

```

Try it online!

Uses the builtin function `id` to avoid assigning a new variable before the loop.
`os.urandom(size)` returns a `bytes` object with `size` random bytes. The `bytes` object behaves quite similar to a list of integers, which means `os.urandom(1)[0]` gives a single random integer from \\$\[0,255\]\\$, which we map to an integer from \\$\[0,99\]\\$ with a modulo operation.

---

# Python 3.8, 53 bytes

Generates integers from a uniform distribution over \\$\[0, 99\]\\$.

```
from random import*
while id:print(id:=randint(0,99))

```

Try it online!
> 11 votes

# Answer
# MathGolf, 5 bytes

```
♀(wo▲

```

Try it online.

**Explanation:**

```
    ▲  # Do-while true (!=0) with pop,
       # using the entire program implicitly as inner code-block:
♀      #  Push 100
 (     #  Decrease it to 99
  w    #  Pop and push a random integer within the range [0,99]
   o   #  Print it with trailing newline (without popping)

```
> 10 votes

# Answer
# Batch, 48 bytes

```
@set n=%random:~-2%
@echo %n%
@if %n% gtr 0 %0

```

Works by taking the random number as a string and extracting the last two digits. (But the comparison is a numeric comparison so 00 still compares equal to 0.) 50 bytes if leading zeros are not allowed:

```
@set/an=%random%%%100
@echo %n%
@if %n% gtr 0 %0

```
> 9 votes

# Answer
# Bash (coreutils), 22 bytes

```
shuf -ri0-99|sed /^0/q

```

Try it online!

Bash is amazingly short here.

Using the little-known sed `q` (quit) command.
> 8 votes

# Answer
# PowerShell, 24 bytes

```
for(;$x=random 100){$x}0

```

Try it online!
> 7 votes

# Answer
# Pyth, 6 bytes

```
W
O100

```

Try it online!

---

Python 3 translation:

```
from random import randrange
def n(b):
    print(b)
    return b

while n(randrange(100)):
    pass

```
> 7 votes

# Answer
# x86-16 DOS .COM file, ~~15~~ 10 bytes

Machine code:

```
00000000: 0f c7 f0 d4 64 cd 29 75 f7 c3                    ....d.)u..

```

Assembly:

```
        // sed -i -e 's#//#;#g' dosrand.asm
        // nasm -f bin dosrand.asm -o dosrand.com
        [bits 16]
        org 100h
        section .text
start:
.loop:
        // don't mind the completely non-suspicious AVX instruction
        // ax -> rand()
        rdrand  ax
        // al -> al % 100
        // ah -> al / 100
        // set flags on al
        aam     100
        // putchar(al)
        int     29h
        // Loop if aam didn't return zero
        jnz     .loop
.end:
        // return to dos (jumps to 0000h which is int 20h)
        ret

```

Try it online! (`int 29h` simulated with `pushf/popf` and `putchar`)

This binary needs a 2013 processor running a 1981 operating system. Nothing weird here.

Specifically, it requires the `rdrand` instruction introduced in Ivy Bridge. However, QEMU supports this even on non-x86 hosts with `-cpu max`.

Prints raw bytes to stdout.

I might make a version for i386 using `printf` later, but I like this meme better.

Thanks to 2x-1 for recommending `int 29h` and saving 5 bytes!

Note that a solution using `mov al, 100; out 41h, al; in al, 41h` was suggested for a portable alternative, but I was unable to get it to work properly; they either infinite looped or the data wasn't random enough depending on the DOS implementation I used (NTVDMx64, DOSBOX, and QEMU/FreeDOS).
> 7 votes

# Answer
# Java (JDK), 61 bytes (recursive)

```
Object f(){int r=100;return(r*=Math.random())<1?r:r+" "+f();}

```

Try it online!

```
Object f(){         // Method returning an Object because it either returns an Integer or a String.
 int r=100;         // Initialize r as an int(eger) to 100.
 return             // The rest can be inlined, so use the return here.
  (
   r*=Math.random() // Multiply 100 by a random double number in range [0,1).
                    // Also, *= is a compound operator that implies a cast,
                    // therefore changing the double to an int at no cost.
                    // So now, r is an integer in range [0,100).
  )<1?              // If the multiplied number is zero (the only possible value below 1)
    r               // Return r as an int, which is automatically boxed to an Integer.
                    // Technically, r is 0, so I could have written 0 instead of r
                    // This is the recursion-closing branch.
   :                // Otherwise
    r+" "+f();      // Return a String, composed of r, a space and the result of the next call to f()
                    // which may either be another String or 0.
}

```

# Java (JDK), 64 bytes (iterative)

```
v->{for(int r=1;r>0;System.out.println(r*=Math.random()))r=100;}

```

Try it online!

## Credits
> 6 votes

# Answer
# Raku, 19 bytes

```
{{100.rand+|0}...0}

```

Try it online!
> 6 votes

# Answer
# APL (Dyalog Unicode), ~~15 11 10 33~~ 16 bytes

```
100,∘?⍨⍣{0=⊃⌽⍺}⍬

```

Try it online!

A full program which outputs the numbers separated by spaces.

Uses `⎕IO←0` (0-indexing).

-4 then -1 byte from Adám.

-19 bytes from 1\_am\_Jack.
> 5 votes

# Answer
# Retina, 25 bytes

```
./^0/^{L$`^
99*
\L@$`
$.`

```

Try it online! Explanation:

```
.

```

Suppress the default output.

```
/^0/^{

```

Repeat until the value is zero.

```
L$`^
99*

```

Replace the value with 99 `_`s.

```
\L@$`
$.`

```

Take the length of a random prefix and also output it on its own line.
> 5 votes

# Answer
# Jelly, 8 bytes

```
³X’+ƲƬI;

```

Try it online!

## Explanation

```
³X’+ƲƬI;   Main niladic link
     Ƭ     Repeat and collect results until there's a duplicate result
    Ʋ      (
³            100
 X           Choose a random number from 1 to 100
  ’          Decrement (to get a number from 0 to 99)
   +         Add to the current value
    Ʋ      )
      I    Increments (deltas)
       ;   Join with the implicit argument, 0

```
> 5 votes

# Answer
# Factor, 29 bytes

-4 bytes thanks to @Bubbler.

```
[ 100 random dup . 0 > ] loop

```

Try it online!
> 5 votes

# Answer
# Phooey, 9 bytes

```
(&~r99$c)

```

Try it online!

Dumps raw bytes to stdout.

```
(      do
  &      set cell to 0 by popping from empty stack
  ~r99   generate random from cell to 99
  $c     print as byte
)      while cell is nonzero

```

# Phooey, integer output, 12 bytes

```
(&~r99$i" ")

```

Try it online!

Does the same thing, only instead of printing as a raw byte, it prints it as an integer and adds a space.
> 5 votes

# Answer
## Javascript (V8), 39 bytes

-4 bytes thanks to Redwolf Programs and aaaidan.

```
do print(a=Math.random()*99|0);while(a)

```

---

## Javascript (V8), ~~45~~ 43 bytes

-2 bytes thanks to EasyasPi.

```
do{a=~~(Math.random()*99);print(a)}while(a)

```

```
do {
  a = ~~ (Math.random()*99);
  print(a)
} while(a)

```

Uses a double bitwise NOT operator (~), as a substitute for Math.floor.

Try it online!
> 5 votes

# Answer
# Random Brainfuck, 37 bytes

```
+[>-[>++<-----]>--[->?[<<+>>[-]]<]<.]

```

Try it online!

This answer is inspired by EasyasPi's solution, but I am avoiding modulo by not even trying to get a uniform distribution. This theoretically should work, but practically will take a long time to finish. If you change the code setting the cell to 100 to a lower number you will see that it indeed terminates at some point.

```
+                          ; initialise cell[0] with 1
[
    >                      ; make cell[1] the new cell[0]
    -[>++<-----]           ; set cell[1] to 100
    >--
        [->?[<<+>>[-]]<]   ; 100 times increment cell[0] with some probability
    <
    .                      ; print cell[0]
]                          ; until cell[0] is 0

```
> 5 votes

# Answer
# Perl 5, ~~26 23~~ 21 bytes

*@KjetilS's comment inspired me to save even more bytes than suggested, and @DomHastings got another 2 bytes off by changing to `$=`*

```
say$==rand 100while$=

```

Try it online!
> 4 votes

# Answer
# 05AB1E, 8 bytes

```
[99ÝΩ=_#

```

Try it online.

**Explanation:**

```
[         # Start an infinite loop:
 99Ý      #  Push a list in the range [0,99]
    Ω     #  Pop and push a random integer from this list
     =    #  Print it with trailing newline (without popping)
      _   #  Pop and if this integer is 0:
       #  #   Stop the infinite loop

```
> 4 votes

# Answer
# C (gcc), ~~59~~ \\$\cdots\\$ ~~44~~ 42 bytes

Saved 2 bytes thanks to dingledooper!!!
Saved a byte thanks to Davide!!!

```
f(i){for(;printf("%d ",i=rand()%100),i;);}

```

Try it online!

Keeps on printing random integers in \\$\[0,99\]\\$ until \\$0\\$ is printed.
> 4 votes

# Answer
# CJam, ~~10~~ 9 bytes

```
{S100mr}h

```

**Try it online!**

Prints each number with a space before it.

### How it works

```
{       }h    e# Do-while loop, withput consuming the condition. Nonzero is truthy
 S            e# Push space
  100         e# Push 100
      mr      e# Random integer with uniform distribution on [0 1 2 ... 99]
              e# Implicit output

```
> 4 votes

# Answer
# Python 3, ~~66~~ 56 bytes

```
from random import*
x=1
while x:x=randint(0,99);print(x)

```

Try it online!

Thank you to xnor, danis and mhawke for showing new stuff and helping improve the code!
> 4 votes

# Answer
# Ohm v2, 10 bytes

```
⁸‹#£D§D,X‽

```

Try it online!

**Commented:**

```
⁸‹#          push a list containing the integers in the range [0-99]
   £    X‽   while the the picked number is not 0
    D        duplicate the list and
     §D,     pick a random number from the list and display it

```
> 4 votes

# Answer
# C (gcc), 40 bytes

```
f(r){printf("%3d",r=rand()%100)*r&&f();}

```

Try it online!
> 4 votes

# Answer
# Lua, 43 bytes

```
repeat a=math.random(0,99)print(a)until a<1

```

Try it online!
> 4 votes

# Answer
# Orst, 25 bytes

```
{100ZЉΞªκ}{ªΐŌ}Ꮳΐ

```

Try it Online!

Yes, Caird, I used one of your esolangs to answer your challenge.

## Explained

```
{100ZЉΞªκ}{ªΐŌ}Ꮳΐ
               Ꮳ   # While:
{100ZЉ             #   A random number chosen from the range [0, 100] is truthy
      Ξªκ          #   And stored in variable y
         }
          {ªΐŌ}    # Print that number
                ΐ  # Push 0 and print that too

```
> 4 votes

# Answer
# Zsh \+ coreutils, 24 bytes

```
shuf -i0-99|grep -xB99 0

```

Try it online!

`shuf`fle the `i`ntegers `0-99`, then search (`grep`) for a line that e`x`actly matches the pattern `0`, outputting the `99` lines `B`efore that.
> 3 votes

# Answer
## Javascript (JQuery) 31 bytes

```
while(alert(a=$.now()%100)||a);
```

```
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
```
> 3 votes

# Answer
# TSQL, 52 bytes

```
DECLARE @ INT A:SET @=RAND()*100PRINT @;IF @>0GOTO A

```

Probably shorter ways to do this. Declaring the variable as an integer means we don't have to explicitly call a `ROUND` or `FLOOR` function. A `GOTO` loop is shorter than a `WHILE` loop.
> 3 votes

# Answer
# Bash, 60 bytes

```
while true;do echo $(($RANDOM%100));done|grep -B99999 -m1 ^0

```

Try it online!
> 3 votes

# Answer
# Wolfram Language (Mathematica), 30 bytes

```
While[Echo@RandomInteger@99>0]

```

Try it online!
> 3 votes

# Answer
# Vyxal, 6 bytes

```
{₁ʁ℅…|

```

Try it Online!

I'm actually quite happy with the way this one turned out. It's always fun when you can print things in the loop's condition.

## Explained

```
{₁ʁ℅…|
{      # Open a while loop which loops while:
 ₁ʁ    #      From the range [0, 100)
   ℅   #      A randomly chosen item is truthy (non-0)
    …  #      (Print that value without popping it)
     | # Branch to the empty body of the while loop

```

In summary, this works by randomly choosing and printing a random number in the range \[0, 100) until that value is 0.
> 3 votes

# Answer
# PowerShell, ~~45~~ ~~36~~ 31 bytes

```
$x=1;while($x){($x=random 100)}

```

Try it online!

Shameless port of Python 3 verbose answer by @Gotoro!

-5 bytes thanks to @Zaelin
> 3 votes

# Answer
# Icon, 39 bytes

```
procedure f()
write(r:=|?100-1)&r=0
end

```

Try it online!

Please note that `link random` is needed for the `randomize()` function, because the output in TIO is always the same. The `random` function in Icon is `?`

## Explanation:

`?100` returns a random integer in the range 1..100

`|?100` turns it into a generator

`|?100-1` subtract 1, so that the random number is in the range 0..99

`r:=|?100-1` assign the value to a variable `r`

`write(r:=|?100-1)` prints the value

`&r=0` if `r` is not zero, backtrack and generate a new value
> 3 votes

# Answer
# Pyth, 10 bytes

```
WnTZ=TO99T

```

Try it online!

---

Explanation:

```
W            # while loop
 nTZ         # compare T (initially 10) not equal to Z (initially 0)
    =TO99    # assign T to a random number from 0 to 99
         T   # output T

```
> 3 votes

# Answer
# Julia, 27 bytes

```
while 0<@show rand(0:99)end

```

Try it online!
> 3 votes

# Answer
# TI-BASIC, 14 bytes

```
Repeat not(Ans
int(E2rand
Disp Ans
End

```

Uses E2 as a shortcut for 10^2=100 to save a byte along with int(rand to save bytes over randInt( - Ans also makes a useful appearance
> 3 votes

# Answer
# Zsh,~~54~~ 47 bytes

***-1 bytes** by using `/dev/random` (@EasyasPi), **-2 bytes** by using `$_` instead of assigning a new parameter, **-4 bytes** by reading a line instead of a single character.*

```
read -u0 c</dev/random
echo $[#c%100]
((_))&&$0

```

Try it online! (uses `/dev/urandom` instead due to TIO's jail)

Bash and Zsh's `$RANDOM` does not qualify as an independent RNG. The first call is random, but subsequent calls are intentionally deterministic. So we have to make our own, reading a line from /dev/random. We get the codepoint of the first character with `#c`.

Finally, the `$_` parameter is the last argument of the previous command, which saves us having to do `$[x=#c%100]`.

The TIO link uses a function, but this will also work as a standalone program (just mind the recursion)
> 3 votes

# Answer
# Red, 32 bytes

```
until[0 = probe -1 + random 100]

```

Try it online!
> 3 votes

# Answer
# Red, ~~38~~ 36 bytes

```
until[print p:(random 100)- 1 0 = p]

```

Try it online!
> 2 votes

# Answer
## Octave/MATLAB with Statistics Package/Toolbox, ~~31~~ 29 bytes

```
@()[randi(99,1,geornd(.1)) 0]

```

Anonymous function that takes no inputs and outputs a row vector.

This uses a modification of the approach described in the second paragraph of the challenge, with the probability of `0` being `1/10` and the probability of each of `1`, `2`, ... , `99` being `1/110`.

**Try it online!**
> 2 votes

# Answer
# F#, 72 70 bytes

-2 bytes: changed number from "a= -1" to "a=1" (typo)

```
let mutable a=1
while a<>0 do a<-System.Random().Next(99);printfn"%i"a

```

Try it online!

There probably would be a way of doing this in a more functional manner, but this is what I've come up with.
> 2 votes

# Answer
# Charcoal, 10 bytes

```
Ｗ‽¹⁰⁰⟦Ｉι⟧0

```

Try it online! Link is to verbose version of code. Explanation:

```
Ｗ‽¹⁰⁰

```

Repeat while a randomly chosen integer from `0` to `99` is non-zero...

```
⟦Ｉι⟧

```

... print the integer on its own line. (Appending a separator doesn't help because the string needs to be separated from the following code.)

```
0

```

Print a `0`.
> 2 votes

# Answer
# SQLite, 156 bytes

```
with
t as (select 1 x union all select abs(random())%100 from t limit 1e5),
s as (select group_concat(x) s from t)
select substr(s,3,instr(s,',0,')-1) from s

```

Try it online!
> 2 votes

# Answer
# Scala, 65 bytes

```
def f=Seq.fill(99999)(util.Random.nextInt(100)).takeWhile(_>0):+0

```

Try it online!
> 2 votes

# Answer
# Nim, 61 60 bytes

```
import random
randomize()
var x=1
while x>0:x=rand 99;echo x

```

Try it online!

*-1 byte thanks to Danis*
> 2 votes

# Answer
# PHP, ~~37~~ ~~36~~ ~~35~~ 33 bytes

```
for(;$n??1;)echo$n=rand(0,99),~_;

```

Try it online!

Another great way to save 2 bytes by Sisyphus with the PHP 7 `??` operator, and no more preceding space!

# PHP, 35 bytes

```
for(;(print~_.$n=rand(0,99))&&$n;);

```

Try it online!

No answer yet for the language we love to hate? Having to display the last zero is not optimal, still trying to get rid of it..

**EDIT**: finally got rid of the extra display for the zero, with a preceding space

# PHP, 36 bytes

```
a:echo~_.$n=rand(0,99);if($n)goto a;

```

Try it online!

A 36 bytes version with an infamous goto, also with a preceding space
> 2 votes

# Answer
# Befunge-98 (Rc/Funge-98) \+ RAND fingerprint, 17 bytes

```
#@_"DNAR"4('dI:.!

```

It doesn't work on TIO with FBBI nor with PyFunge because they don't have the RAND fingerprint implemented.
> 2 votes

# Answer
# Racket, 58 bytes

```
(define(f[r(random 100)])(and(writeln r)(when(< 0 r)(f))))

```

Try it online!
> 2 votes

# Answer
# K (oK), ~~18~~ 16 bytes

```
(*|){x,1?100}/""

```

Try it online!
> 2 votes

# Answer
# Haskell, 67 bytes

*Creates a monad containing the random list*

```
import System.Random
m=randomRIO(0,99)>>=k
k 0=pure[0]
k x=(x:)<$>m

```

Try it online!

# Haskell, 80 bytes

*Complete program*

```
import System.Random
main=randomRIO(0,99::Int)>>=k;k 0=print 0;k x=print x>>main

```

Try it online!
> 2 votes

# Answer
## Swift, ~~57~~ ~~54~~ 51 bytes

```
var a=1;while a>0{a=Int.random(in:0...99);print(a)}

```

```
var a = 1                    // Set last randomly generated value to 1 as magic value
while a > 0 {                // End when a == 0
  a = Int.random(in: 0...99) // Generate new random number
  print(a)                   // Print number
}

```

-1 byte after reading comment by @Danis saying I can use `>` instead of `!=`, other 2 bytes from removing whitespace (`a!=0` makes Swift think that I'm unwrapping `a`)

-1 byte after other comment

-2 bytes after removing whitespace
> 2 votes

# Answer
# AWK, 51 bytes

```
{for(srand(systime());$++x=int(100*rand()%100););}1

```

This works by assigning positional variables random numbers until a 0 is generated.

The awfully long,

```
srand(systime())

```

line is needed to seed the random number generator. I couldn't find a shorter way to do that without passing in random info from outside the script.

The only other trick here is using a "truthy" test with no action, which trigger AWK to print all the positional variables by default.

Try it online!

# Ly, 9 bytes

```
1[!'c?:]+

```

I found two the same length in `Ly` but I like this one better since it's quirkier IMO. :)

```
1         - need truthy value on the stack to start the loop
 [     ]  - loop until the top of stack is "0"
  !       - map top of loop number to "0"
   'c     - push "99"
     ?    - generate a random number in 0-99 range
      :   - duplicate the top of stack
        + - top two entries will be "0 0", add to consume one
          - numbers on the stack print automatically on exit

```

The other nine character one is `'cs?[0l?]` which is similar, but more straightforward.

Try it online!
> 2 votes

# Answer
# ARM Thumb-2 machine code (Linux, no libc/div), 34 bytes

Machine code:

```
4668 2101 2203 01d7 df00 4669 2201 2704
780d 3d64 d8fd 3564 700d df00 d1f0 2701
df00

```

Commented assembly:

```
        .syntax unified
        .arch armv6t2 // technically ARMv4T compatible
        .thumb
        .globl _start
        .thumb_func
_start:
.Lloop:
        // It sucks that this takes the buffer in r0. :(
        // buf = sp
        mov     r0, sp
        // size = 1
        movs    r1, #1
        // flags = GRND_RANDOM | GRND_NOBLOCK = 3
        // 0 is preferred, but this allows us to cheat loading the getrandom
        // syscall which won't fit in a narrow movs.
        movs    r2, #3
        // getrandom = 0x180 = 3 << 7
        // no movw required
        // movw r7, #0x180
        lsls    r7, r2, #7
        // getrandom(&x, 1, GRND_RANDOM | GRND_NOBLOCK)
        svc     #0

        // getrandom for sizes < 256 return 1 in r0, as long as it isn't
        // interrupted, blocked, or out of entropy, corner cases I don't care
        // about. :P

        // fd = stdout
        // movs r0, #1
        // buf = sp
        mov     r1, sp
        // len = 1
        movs    r2, #1
        // write = 4
        movs    r7, #4

        // load the random byte returned by getrandom()
        // note: ldrb r5, [sp] is a wide instruction. :(
        ldrb    r5, [r1]

        // modulo 100 using subtraction loop
        // x %= 100
.Lmodloop:
        subs    r5, #100
        bhi     .Lmodloop
.Lmodloop.end:
        // note: this sets the zero flag which is preserved in syscalls
        adds    r5, #100

        // store the random byte mod 100 back to [r1]
        strb    r5, [r1]
        // write(1, &x, 1);
        svc     #0
        // syscalls preserve flags, so loop if
        // the value was zero.
        bne     .Lloop
.Lloop.end:
        // exit
        movs    r7, #1
        // exit(dontcare)
        svc     #0

```

Not gonna win any golfing contests, but I'll post it anyways cuz it is pretty well golfed for what it is.

No libc, only uses the `getrandom`, `write`, and `exit` syscalls.

Prints raw bytes to stdout, hence why the demo is piped to `xxd`.

Try it online! (sorta) (Travis demo)
> 2 votes

# Answer
# Wolfram Language (Mathematica), 54 bytes

```
NestWhile[Append[#,Echo@RandomInteger@99]&,{},FreeQ@0]

```

Try it online!

It basically does the same thing as att's 30 byte solution, but additionally it returns the collection of random values as a list, rather than `Null`
> 2 votes

# Answer
# Bash, 46 45 bytes

```
until(echo $((RANDOM%100));exit $_);do :;done

```

Try it online!

*-1 byte thanks to EasyasPi*
> 2 votes

# Answer
# Befunge-98, ~~19~~ 13 bytes

*-3 bytes thanks to @ovs!*

```
?+<1
<@w.:%d'

```

Try it online!

Generates each number according to a geometric distribution modulo 100.

## Explanation

The instruction pointer (IP) starts at the `?` in the top left corner, which sends it in a random direction. If it goes right, the `<` turns it around back to the `?`, and the `+` (which is executed twice, once in each direction) adds 0 to the current number. If it goes left, `1` puts a 1 on the stack, `<` sends the IP back to `?` again, and `+` adds the 1 to the number (which, given an empty stack, starts at zero). As long as `?` keeps sending the IP left, this can happen arbitrarily many times, so there is a nonzero chance of reaching each number.

If the IP goes up or down, `<` turns it onto the second line, which processes the number.

```
 @w.:%d'

    :       Copy
   .             and print
     %                     the number modulo
      d'                                     100.
  w         If the copy is zero,
 @                               end the program.

```

If the printed result was greater than zero, `w` sends the IP up to the first line, and `<` starts the program over from the beginning.
> 2 votes

# Answer
# Pxem, Filename: ~~23~~ 17 bytes + Content: 0 bytes = ~~23~~ 17 bytes, depends on ASCII-compatible encoding.

* Filename: `d.!.t.w.m.r.c.n,.o.a`
* Content: empty

## Commented

```
d.t  # heap = 100
.w # loop
  .m.r # push(random(min=0,max=heap-1))
  .c # dup()
  .n # printf("%d",pop())
  ,.o # putchar(',')
.a # break if pop()==0

```
> 2 votes

# Answer
# \>\<\>, 50 bytes

```
701>x1>$:2*}*+ }1-:?!v}30.>
   ^\0/.;?=0oan:%*aar<

```

Try it online!

After many iterations, I got down to this version. Pretty happy with it, although I will admit I'm not convinced it's optimal.

## Explanation

The \>\<\> language doesn't have a natural builtin for generating a random number in a range. The only source of randomness we have is the `x` command, which sends the IP in a random direction. This gives us 1 of 4 options, which doesn't immediately fit into the range 0-99. However, we can easily use this command to generate a random bit, 0 or 1, like so:

```
>x1>
^\0/

```

Going in a left-to-right direction, the IP can either be sent leftwards back to the `>`, where it tries again, upwards, wrapping around to try again, rightwards to `1`, or downwards to `0`. This uniformly generates a random bit, although perhaps it can be made shorter by making that not so.

We're going to loop 7 times each time we generate a random number, for 7 bits. This will give us the binary for numbers from 0 to 127—more than we need, but we'll fix that later. Instead of collecting all the bits and subsequently converting that to a decimal number, we'll do both steps at once. `701` initializes the stack with our configuration. `7` is the loop count, `0` is the running sum, and `1` is the multiplicative factor.

`$:2*` will make a copy of the multiplicative factor and double that copy for the next iteration. `}*+` will multiply the generated bit by the multiplicative factor and add it to the sum. `}1-:?!v` will decrement the loop counter, and if it's 0, stop looping. `}30.`, in the event we don't stop, will reorganize the stack for the next iteration and jump back to the beginning (past the initialization).

The second line mostly contains the outer loop. It is written "backwards" to save space. First, `r` will place the generated sum on the top of the stack. `%*aa` will take that value mod 100, giving us a value from 0 to 99, albeit not uniformly. Then, we simply output that number followed by a newline (`oan:`). After that, `;?=0` terminates the program if 0.

We then have a single `.` command, which pops `y` and `x` off the stack and jumps to that location in the code. Since the stack contains `[0, 64]` at this point (the counter and the multiplicative factor, respectively), this jumps to (0, 64). Of course, this position doesn't exist in the code. In the Python implementation (the standard one), the interpreter will first increment this by the delta, which, at the time of execution, is (-1, 0). So, the IP is then (-1, 64) internally. To resolve this, \>\<\> will first fix the y-coordinate, wrapping it around to 0 since it exceeds the bound, giving (-1, 0). When x \< 0, it gets wrapped around to the end of the line, hopping to (28, 0), which is the `>` command. This puts us back on the right direction and back at the beginning of the line.

## Catalogue of Attempts

**103 bytes:** My first attempt. Completely ungolfed. First collects the bits, then converts it to a decimal in a separate stage.

```
7>x1>$1-:?!v!
 ^\0^   v$1<
{2*$l2=?\@:}*+
  !     >:0=?v:'d'(?v     >0[700.
           ;n<      >n' 'o^

```

**105 bytes:** Post calculating the sum while collecting bits. Longer, but the structure offers us more opportunities to golf.

```
701>x1>$:}*+}1-:?!v}2*30.
   ^\0^           >r:0=?v:'d'(?v     >0[700.
                      ;n<      >n' 'o^

```

**90 bytes:** Introducing the modulus trick, rather than retrying if the number is 100 (`'d'`) or more.

```
701>x1>$:}*+}1-:?!v}2*30.
   ^\0^           >r:0=?vaa*%nao0[700.
                      ;n<

```

**64 bytes:** Inlining the terminate-if-zero condition.

```
701>x1>$:}*+}1-:?!v}2*30.
   ^\0^           >raa*%:nao0=?;0[700.

```

**54 bytes:** Moving the modulo calculation into the main loop so we have enough room to flip the second line and tuck it into the whitespace we have.

```
701>x1>$:}*+aa*%}1-:?!v}2*30.>
   ^\0/     .;?=0oan:r<

```

**53 bytes:** Since we have spare whitespace left, we can use it to set the pointer in the right direction to save the `>` off the first line. Since that means we're jumping to the beginning of the line, we'd naturally skip `7`, so we have to duplicate it before we jump.

```
701>x1>$:}*+aa*%}1-:?!v}2*30.
   ^\0/ #.!@7;?=0oan:r<

```

This approach, however, left me at a dead end, so I tried putting the modulo calculation back into the second part, which leaves us with what we currently have.
> 2 votes

# Answer
# C (clang), ~~87~~ ~~60~~ ~~58~~ 54 bytes

```
main(a){for(srand(&a);printf("%d ",a=rand()%100),a;);}

```

Try it online!

Learned new functions thanks to this.

Thanks to caird coinheringaahing, along with the help of a stone arachnid, for golfing 27 bytes. Thanks to a stone arachnid for golfing another 2 bytes. Thanks to ceilingcat for golfing 4 bytes.
> 2 votes

# Answer
# Pip, 7 bytes

```
W PRRhx

```

Try it online!

### Explanation

```
W        While
   RRh   random integer in [0, 100)
  P      printed
         is truthy (nonzero):
      x   No-op

```
> 2 votes

# Answer
# Tcl, 54 bytes

```
while {[set R [expr int(rand()*99)]]} {puts $R}
puts 0

```

Try it online!
> 1 votes

# Answer
# Japt, ~~11~~ 9 bytes

```
Lö
OpU
©ß

```

Test it

Outputs delimited by newlines, with a trailing newline after the 0

```
Lö      # Get a random number from [0...99] and store it as U
OpU     # Print U and a newline
©       # If U is non-zero:
 ß      #  Run the program again
        # Otherwise end with no further output

```
> 1 votes

# Answer
# VBScript, 51 bytes

```
Randomize
Do
r=Int(100*Rnd)
msgbox r
Loop Until r=0

```
> 1 votes

# Answer
# CSASM v2.2.1, 74 bytes

```
func main:
.lbl a
push 100
extern Random.Next(i32)
dup
print.n
brtrue a
ret
end

```

**Commented:**

```
func main:
    .lbl loop
        ; Get a random number in [0, 99]
        push 100
        extern Random.Next(i32)
        ; Duplicate it so it can be printed and then checked
        dup
        print.n
        ; Keep looping as long as the i32 generated is truthy (non-zero)
        brtrue loop
    ret
end

```
> 1 votes

# Answer
# GolfScript, 14/15 bytes

```
{100rand.}do]`

```

Try it online!

Uses `rand` built-in to generate random numbers from 0-99, inside a `do` loop to terminate once a 0 is generated. The output of the loop is collected into an array and formatted for output. If the brackets and quotation marks invalidate the output, here is another version that sacrifices 1 byte for cleaner output:

```
{' '100rand.}do

```

Try it online!
> 1 votes

# Answer
# Knight, 12 bytes

```
W;O=n%R100nT

```

Try it online!

Very simple.

```
# Loop while RANDOM % 100 is non-zero.
# Because we need to output 0 as well, we
# use a semicolon to output first, then check n.
WHILE (; OUTPUT (= n % RANDOM 100):n)
    : TRUE # empty loop body

```

`;` can act sort of like the comma operator in C. It evaluates two statements and returns the second value.

Therefore, it is basically this in C:

```
while (printf("%d\n", n = rand() % 100), n)
    ;

```
> 1 votes

# Answer
# JavaScript, 39 bytes

```
for(x=1;x;)print(x=Math.random()*100|0)

```

Try it online!
> 1 votes

# Answer
# Scala, 151 bytes

Golfed version. Try it online!

```
import scala.util.Random
object A extends App{Stream.continually(new Random().nextInt(100)).takeWhile(_ != 0).foreach(x => print(s"$x "));println("0")}

```

Ungolfed version. Try it online!

```
import scala.util.Random

object Main {
  def randomUntil0(): Stream[Int] = {
    val rnd = new Random()
    Stream.continually(rnd.nextInt(100)).takeWhile(_ != 0)
  }

  def main(args: Array[String]): Unit = {
    randomUntil0().foreach(x => print(s"$x "))
    println("0")
  }
}

```

# How it works?

The task needs to print a sequence of random numbers between 0 and 99 (inclusive) until a 0 is generated. This Scala code achieves the same purpose by defining a randomUntil0 function that generates a Stream of random numbers and takes elements while the number is not equal to 0. The main method iterates over the Stream generated by randomUntil0 and prints the numbers followed by 0.
> 1 votes

# Answer
# Thunno 2, 5 bytes

```
(ɦLɼß

```

Attempt This Online!

#### Explanation

```
(ɦLɼß  # Full program
(      # While loop
 ɦL    # (condition)  Push [0..99]
   ɼ   #              Pop and choose a random item
    ß  #              Print it without popping
       # (This runs until 0 is selected,
       #  since 0 is the only falsy integer)

```
> 1 votes

# Answer
# Swift 5.9, 51 bytes

```
var r=1
while r>0{r = .random(in:0...99)
print(r)}

```

Yes, the whitespace around the second `=` is required.
> 1 votes

# Answer
# Assembly (nasm, x64, Linux), 308 bytes

```
s:mov edi,100
mov eax,edi
mov edx,0
neg eax
div edi
r:rdrand eax
jnc r
imul rax,rdi
cmp eax,edx
jb r
shr rax,32
mov rsi,n
mov ecx,10
l:mov edx,0
div ecx
add dl,48
dec rsi
mov[rsi],dl
cmp eax,0
jnz l
mov rax,1
mov rdi,1
mov rdx,n
sub rdx,rsi
inc rdx
syscall
cmp byte[rsi],'0'
jnz s
section .bss
resb 2
n:

```

Try it online!

# How it works?

The nasm code implements Lemire's Method which gives a random number between 0 and 100, not including 100 itself. It ports Lemire's Method from C to nasm:

```
uint32_t bounded_rand(rng_t& rng, uint32_t range) {
    uint32_t t = (-range) % range;
    do {
        uint32_t x = rng();
        uint64_t m = uint64_t(x) * uint64_t(range);
        uint32_t l = uint32_t(m);
    } while (l < t);
    return m >> 32;
}

```
> 1 votes

# Answer
# Python, 44 bytes

```
i=s='a'
while i:print(i:=hash(s)%100);s+='a'

```

Attempt This Online!

Note that Python's string hash randomization makes this produce a different sequence each time you run the program.
> 1 votes

# Answer
# VBA ~~38~~ ~~37~~ 39 bytes

Is the exit on error allowed? I just wanted to use the division by zero error...

```
Do
a=(Rnd*99)\1
Cells(1+a)=a
a=1/a
Loop

```

### Update:

Added two bytes `+a` to the 3rd line to avoid rewriting the previous numbers.
> 1 votes

# Answer
# Uiua, 17 bytes

```
⇌⍢(⊂⌊×100⚂|±/×)[]

```

Try it on the pad!
> 1 votes

# Answer
# Thunno, \\$ 11 \log\_{256}(96) \approx \\$ 9.05 bytes

```
[Z2RZwD!)ZK

```

(No ATO link since this requires v1.2.2)

#### Explanation

```
[Z2RZwD!)ZK
[            # Forever:
    Zw       #  Get a random element of
 Z2R         #  range(100)
      D      #  Duplicate
       !)    #  Break if 0
         ZK  #  And print the number
             # The 0 is implicitly output at the end

```
> 0 votes

# Answer
# Go, 79 bytes

```
package main
import."math/rand"
func main(){for{n:=Intn(100)
println(n)
_=1/n}}

```

Attempt This Online!

Exits with a divide-by-zero error.

### Go, 108 bytes, seeded

```
package main
import(."math/rand";."time")
func main(){Seed(Now().Unix())
for{n:=Intn(100)
println(n)
_=1/n}}

```

Attempt This Online!
> 0 votes

---
Tags: code-golf, random
---