title: Shortest Error Message

text:
# Question
Title: Shortest Error Message
**Challenge**

Write the shortest program that, when compiled or executed, produces a fatal error message smaller than the program itself. The error message may not be generated by the program itself, such as Python's `raise`. A valid answer must include both the code and the error message. Shortest valid answer wins.

No error message does not count as an error message.

**Example (Lua)**

Code (46 bytes):

```
[
--aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

```

Error (45 bytes):

```
[string "[..."]:1: unexpected symbol near '['

```

# Answer
> 67 votes
# ed, 3 bytes

*Note: Most of the answers here are ignoring the trailing newline printed as part of the error message in their count. But I don’t see anything in the question to justify ignoring it, and the author commented that the newline should be included. So unless the question is changed, I’m going to include it.*

Code (with trailing newline):

```
??

```

Error (with trailing newline):

```
?

```

# Answer
> 58 votes
# C (modern Linux), 19 bytes

Would've done my famous segfault but totallyhuman stole it.

```
main(){longjmp(0);}

```

Output (18 bytes):

```
Segmentation fault

```

# Answer
> 57 votes
# Python 2, 35 bytes

```
import sys;sys.tracebacklimit=000;a

```

Gives error:

```
NameError: name 'a' is not defined

```

# Answer
> 36 votes
## JavaScript (Firefox), 31 bytes

```
# This is a comment, right? ...

```

Throws this error:

```
SyntaxError: illegal character

```

Tested in the console of Firefox 54.0.1 on Windows 7.

# Answer
> 28 votes
# Python 2, ~~87~~ 79 bytes

*-8 bytes thanks to Zacharý and Erik the Outgolfer.*

```
from __future__ import braces
#i am most surely seriously actually totallyhuman

```

Try it online!

## Error message, 78 bytes:

Assuming the code is stored in a file named `a`.

```
  File "a", line 1
    from __future__ import braces
SyntaxError: not a chance

```

This is actually a nice little Easter egg in Python. :D

# Answer
> 25 votes
# Haskell, 13 bytes

```
main = (main)

```

Save as `t.hs` or another one-character name, compile with `ghc`, and run. Error message (with trailing newline):

```
t: <<loop>>

```

# Answer
> 20 votes
# \>\<\>, 26 bytes

```
>>>>>>>>>>>>>>>>>>>>>>>>>:

```

Try it online!

Every error message in Fish is `something smells fishy...`, so this just moves the pointer right enough times to be longer than that and attempts to duplicate the top of the stack, which is empty at the time.

# Answer
> 20 votes
# Taxi, ~~38~~ 21 bytes

```
Switch to plan "abc".

```

Produces:

```
error: no such label

```

Try it online!

*-17 bytes thanks to Engineer Toast*

Tries to switch to "abc", which does not exist. You would have `[abc]` somewhere.

# Answer
> 20 votes
# System V shell, 25 bytes

```
mount /dev/hda1 /mnt/hda1

```

Error message (23 bytes):

```
mount: not a typewriter

```

"Not a typewriter" or `ENOTTY` is an error code defined in `errno.h` on Unix systems. This is used to indicate that an invalid ioctl (input/output control) number was specified in an ioctl system call. On my system, in `/usr/include/asm-generic/errno-base.h`, I can find this line:

```
#define ENOTTY          25      /* Not a typewriter */

```

In Version 6 UNIX and older, I/O was limited to serial-connected terminal devices, such as a teletype (TTY). These were usually managed through the `gtty` and `stty` system calls. If one were to try to use either of these system calls on a non-terminal device, `ENOTTY` was generated.

Nowadays, there is naturally no need to use a teletype. When `gtty` and `stty` were replaced with `ioctl`, `ENOTTY` was kept. Some systems still display this message; but most say "inappropriate ioctl for device" instead.

# Answer
> 20 votes
## JavaScript (Firefox), 21 bytes

```
(a=null)=>a.charAt(1)

```

**Error (20 bytes)**: `TypeError: a is null`

# Answer
> 14 votes
# TrumpScript, 30 bytes

```
We love NATO!
America is great

```

Error message:

```
Trump doesn't want to hear it

```

# Answer
> 12 votes
# **Javascript (V8), 24 bytes**

```
decodeURIComponent('%');

```

Error, 23 bytes:

```
URIError: URI malformed

```

Tested on *Nodejs v6.11.0* and *Google Chrome v59.0.3071.115*.

Try it online!

Note that TIO expands the error message.

# Answer
> 11 votes
# QBasic, 11 bytes

There are two solutions of 11 bytes in QBasic, one of which might be golfed further. The shortest error message QBasic has is `overflow`, and can be triggered as such:

```
i%=i%+32677

```

This throws `overflow` because the max for an integer (`i%`) is `32676`. I couldn't get the `32677` golfed without QBasic auto-casting this to long...

Another error, at 11 bytes, would be `out of data`. QBasic has `DATA` statements that store data in the program, which can later be accessed by `READ` statements. Issuing more `READ`s than `DATA`s causes the error:

```
READ a$ '--

```

Note that the statement is padded with a comment to get it up to the length of the error message. Yes, I have an error message with a shorter program, and a program with a shorter error message ...

# Answer
> 11 votes
# Vyxal, 309 bytes

```
In this answer, I coded it so that the program errors when executed․
Also, according to code-golf statistics, only a small percentage of people who view my answers actually upvote․
So if you enjoy this answer, please consider upvoting - it's free, and you can change your mind at any time․
Enjoy the answer․

```

I request that you imagine Epic Dawn by Bobby Cole is playing while reading this answer.

## The Error

```
Traceback (most recent call last):
  File "C:\Users\61419\Desktop\Vyxal\Vyxal.py", line 867, in <module>
    exec(line)
  File "<string>", line 4, in <module>
  File "C:\Users\61419\Desktop\Vyxal\Vyxal.py", line 592, in VY_int
    return int(item, base)
ValueError: invalid literal for int() with base 10: ''

```

# Explained

This fails immediately on the first instruction it sees: `I`. It tries to convert the empty input to base 10 (which is impossible)

# Answer
> 10 votes
# C (Modern Linux), 19 bytes

I suggested this in chat, but nobody took the oppurtunity. :P Credit to MD XF's hilarious answer.

```
main(){puts('s');;}

```

## Error message, 18 bytes

```
Segmentation fault

```

# Answer
> 10 votes
## Commodore 64 Basic, 15 bytes

```
?SYNTAX   ERROR

```

Produces

```
?SYNTAX  ERROR

```

(Note two spaces in the error message, where the program has three)

`?SYNTAX ERROR` is tied with `?VERIFY ERROR` as the third-shortest error message that C64 Basic can produce, and the shortest that can be reliably triggered by code (the shortest message, `BREAK IN 1`, requires user interaction, while `?LOAD ERROR` requires a defective tape or floppy disk, and `?VERIFY ERROR` requires the presence of a floppy or tape containing a file that doesn't match the program in RAM).

# Answer
> 9 votes
# PowerShell, ~~215~~ 189 bytes

```
[]
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

```

Try it online!

So, PowerShell has ... verbose ... error messages. Additionally, most non-syntax error messages are Runtime Exceptions, meaning that they're non-fatal, which reduces this problem to needing to find a short parsing error.

~~I *think* this is one of the shortest, if not *the* shortest,~~ @TessellatingHeckler has demonstrated this is the shortest parsing error, and it still weighs in at `188` bytes just for the error message. So we basically need to append enough `1`s to reach `189` bytes of "code."

Running this locally on `c:\a.ps1` for example, will cut down on the byte count by a handful as it's just a shorter file path, but then it's not available on TIO.

Produces error:

```
At /tmp/home/.code.tio.ps1:1 char:2
+ []
+  ~
Missing type name after '['.
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : MissingTypename

```

# Answer
> 7 votes
# , ~~29~~ 28 bytes

*-1 byte thanks to JarkoDubbeldam*

```
a #abcdefghijklmnopqrstuvwxy

```

Throws the error `Error: object 'a' not found`which is 27 bytes.

Try it online!

# Answer
> 7 votes
# Ruby (~~33~~ 32 bytes)

**32 bytes**

```
&
#abcdefghijklmnopqrstuvwxyz12

```

Throws the error (assuming in a file named "a"):

**31 bytes**

```
a:1: syntax error, unexpected &

```

**Edit**: Shaved a byte off by using `&` instead of `<<` thanks to Eric, who also came up with an even shorter Ruby solution: http://codegolf.stackexchange.com/a/135087/65905

# Answer
> 5 votes
# Brainf\**k, 17 bytes, this interpreter

```
+++++++++++++++<<

```

Brainf\**k is such a simple language that almost every interpreter has a different error message. This one uses `Memory Error: -1` for when the pointer is moved to the left too much and you attempt another operation

# Answer
> 5 votes
# Common Lisp, 20 bytes

```
(/ 1 0))))))))))))))

```

Try it online!

**Error Message**

```
/: division by zero

```

# Answer
> 5 votes
# TryAPL, 11 bytes

Code (11):

```
'abcdefghij

```

Error (10):

```
open quote

```

# Answer
> 5 votes
# Perl 5, 11 bytes

Since I'm not clear on whether my other answer obeys the challenge rules, here's another alternative.

```
#line 0
die

```

Error output:

```
Died.

```

With an ending newline, for 6 bytes.

Try it online!

For some reason the Perl interpreter internal function `Perl_mess_sv` contains:

```
if (CopLINE(cop))
    Perl_sv_catpvf(aTHX_ sv, " at %s line %" IVdf,
                    OutCopFILE(cop), (IV)CopLINE(cop));

```

where `CopLINE(cop)` gets the current code context's line number. So if that line number happens to evaluate to zero, Perl skips adding the usual `" at <filename> line <n>"` to the error message.

# Answer
> 5 votes
# ZX Spectrum Basic, 9 bytes

```
RUN USR 8

```

produces:

Explanation:

I am (exceptionally) counting ASCII representation of the program for length purposes, including the end of line (it's not really important, since we could always pad a shorter program with spaces).

Usually, ZX Spectrum error messages are longer and more helpful than this - the ROM routine at 0x0008 expects error code following the machine code call to `RST 8`., and fetches some random (deterministic) byte from the ROM, which produces this nonsensical error message `M`. `5` is the error number, `,` is added by the error printing routine and `0:1` is the line:command position of the error.

# Answer
> 5 votes
# ArnoldC, 150 bytes

```
IT'S SHOWTIME
HEY CHRISTMAS TREE b
YOU SET US UP 0
GET TO THE CHOPPER b
HERE IS MY INVITATION b
HE HAD TO SPLIT 0
ENOUGH TALK
YOU HAVE BEEN TERMINATED

```

Try it online!

Error is 94 bytes (including trailing newline):

```
Exception in thread "main" java.lang.ArithmeticException: / by zero
    at code.main(Hello.java)

```

---

Preserved because I think this is more funny - spoiler: it was those dang teenage pranksters.

# ArnoldC, 280 bytes

```
IT'S SHOWTIME
HEY CHRISTMAS TREE BRBDoorBetterNotBeThosePeskyTeenagePranksters
YOU SET US UP 0
GET YOUR ASS TO MARS BRBDoorBetterNotBeThosePeskyTeenagePranksters
DO IT NOW
I WANT TO ASK YOU A BUNCH OF QUESTIONS AND I WANT TO HAVE THEM ANSWERED IMMEDIATELY
YOU HAVE BEEN TERMINATED

```

Pseudocode:

```
start program
new variable
set to 0
set new variable to output from function
call function
take input
end program

```

Try it online!

Generates a "no input" error. (Almost all other errors in ArnoldC include a large piece of boilerplate):

279 bytes (including trailing newline):

```
Exception in thread "main" java.util.NoSuchElementException
    at java.util.Scanner.throwFor(Scanner.java:862)
    at java.util.Scanner.next(Scanner.java:1485)
    at java.util.Scanner.nextInt(Scanner.java:2117)
    at java.util.Scanner.nextInt(Scanner.java:2076)
    at code.main(Hello.java)

```

# Answer
> 4 votes
# Perl 5, 5 bytes

```
die$/

```

Outputs a newline, for one byte.

Try it online!

# Answer
> 4 votes
# Javascript (Firefox), ~~29~~ 27 bytes

```
new Date('-').toISOString()

```

throws `RangeError: invalid date` which is 24 bytes. Tested on Firefox 54.0.1 on Windows 10.

# Answer
> 4 votes
# GW-Basic, 9 bytes

Enter:

```
?&H100000

```

This will yield the following error message:

```
Overflow

```

I believe this is the shortest error message in GW-Basic. The reason I used a hexadecimal constant is that while GW-Basic doesn't support long integers, it does support single and double(!) precision floating point numbers.

# Answer
> 4 votes
# Whitespace (on TIO), 34 bytes

```

Nope, it's not valid Whitespace!
```

Try it online.

All characters that aren't a space, tab, or newline are ignore in Whitespace. So this program is actually `SNSSS` (where `S` is space, and `N` is newline). The first three (`SNS`) is the command to duplicate the value at the top of the stack. Since the stack is still empty, it gives the error:

```
wspace: user error (Can't do Dup)

```

I tried other errors, but this seems to be the shortest. Most errors where it tries to use a value on the stack which isn't present are similar, but longer. Here is a list of all possible errors (I could find) on TIO (for the first one it requires a character input, which it tries to read and print as number, so I've excluded that one - Try it online.):

```
wspace: Prelude.read: no parse
wspace: user error (Can't do Dup)
wspace: user error (Can't do Swap)
wspace: Prelude.!!: index too large
wspace: user error (Can't do Store)
wspace: user error (Can't do Return)
wspace: user error (Can't do Discard)
wspace: user error (Can't do Slide 0)
wspace: user error (Can't do ReadNum)
wspace: user error (Can't do Retrieve)
wspace: user error (Can't do ReadChar)
wspace: <stdin>: hGetChar: end of file
wspace: <stdin>: hGetLine: end of file
wspace: user error (Can't do OutputNum)
wspace: Prelude.chr: bad argument: (-1)
wspace: user error (Can't do Infix Plus)
wspace: user error (Can't do OutputChar)
wspace: user error (Undefined label ( ))
wspace: user error (Can't do Infix Minus)
wspace: user error (Can't do Infix Times)
wspace: user error (Can't do If Zero " ")
wspace: user error (Can't do Infix Divide)
wspace: user error (Can't do Infix Modulo)
wspace: user error (Can't do If Negative " ")
wspace: Input.hs:(108,5)-(109,51): Non-exhaustive patterns in function parseNum'
wspace: Unrecognised input\nCallStack (from HasCallStack):\n  error, called at Input.hs:103:11 in main:Input
wspace: Stack space overflow: current size 33624 bytes.\nwspace: Relink with -rtsopts and use `+RTS -Ksize -RTS' to increase it.

```

---

NOTE: Whitespace compilers have their own implementations for error messages. All these errors above are on TIO. If I use the online Whitespace compiler vii5ard instead, and use the same program at the top, it will give this error instead:

```
ERROR: Runtime Error: Stack underflow

```

So using the vii5ard online Whitespace compiler I could lower my byte-score to:

# Whitespace (on vii5ard), 15 bytes

```
Unexpected EOF!

```

Which is the 'program' `S` (a single space), resulting in the error:

```
Unexpected EOF

```

(Which would result in `wspace: Unrecognised input\nCallStack (from HasCallStack):\n error, called at Input.hs:103:11 in main:Input` on TIO).

# Answer
> 4 votes
# 05AB1E, ~~410~~ 411 bytes

```
One plus one is two, two plus two is four.
And now, some random character spam just because I can.
3...
2...
1...
GO!

ooi1u4`o1i2)I#1n[09i43u`1@#~!@#{10239`]ι@(~!)2ioausioe7u12o3iu71p3123`71i2`8127l5ruy;3948'p3298rv9pe8huep'r8i19o`8u'3pie8uiouI!^23uT7T17I3YJH~:L'I`YU2O123;121@

That should be about it, it errored. Guess that's what happens when you spam. Bye for now!

upvote if you liked my creativity

:)

```

Try it online!

```
One plus one i...]ι...  # trimmed program
One plus one            # push empty string ("") twice
             i          # if top of stack is truthy...
              ...       # execute (trimmed) code (this is unreachable)
                 ]      # exit all opened statements
                  ι     # not exactly sure what this function does, but part of it forcefully converts top of stack to an integer (without error handling), therefore erroring
                   ...  # unreachable code as program has quit from the fatal error

```

# Error, 410 bytes

```
** (RuntimeError) Could not convert  to integer.
    (osabie) lib/interp/functions.ex:101: Interp.Functions.to_integer!/1
    (osabie) lib/interp/commands/special_interp.ex:113: Interp.SpecialInterp.interp_step/3
    (osabie) lib/interp/interpreter.ex:127: Interp.Interpretr.interp/3
    (osabie) lib/osabie.ex:62: Osabie.CLI.main/1
    (elixir) lib/kernel/cli.ex:105: anonymous fn/3 in Kernel.CLI.exec_fun/2

```

# Answer
> 3 votes
# Aubergine, 53 bytes

```
0/0 Lots of wasted space. I don't know how Aubergine.

```

Outputs `SyntaxError: Invalid instruction (0) at character 0.`

Try it online!

# Answer
> 3 votes
# TI-Basic, 9 bytes

Shortest error messages are 8 bytes each: `ERR:DATE`, `ERR:MODE`, `ERR:STAT`, and `ERR:ZOOM`. I didn't consider `ERR:DATE` because that doesn't work on models without an internal clock. Also, I didn't go for `ERR:ZOOM` because it seemed too hard to trigger.

Program (9 bytes):

```
Seq:DrawInv X:::::

```

Error message: `ERR:MODE` (8 bytes)

Program (9 bytes):

```
median({1},{0::

```

Error message: `ERR:STAT` (8 bytes)

# Answer
> 3 votes
# Ruby, 25 bytes

That was a fun exercise, thanks! There's probably a way to get a shorter error message with a SegFault, but I couldn't find any.

```
/\x
# Invalid hexa regexp

```

Error message:

```
a:1: invalid hex escape

```

24 bytes, including a trailing newline.

Try it online!

# Ruby, 26 bytes

Here's my previous answer:

```
08
# No 8 allowed in octal

```

Error message:

```
a:1: Invalid octal digit

```

25 bytes, including a trailing newline.

# Answer
> 3 votes
# GW-BASIC, 13 bytes

```
-------------

```

Error (12 bytes):

```
Syntax error

```

As GW-BASIC treats anything it doesn't recognize as a syntax error, there are a near-infinite amount of strings of length 13 that I could've used instead of `-------------`

# Answer
> 3 votes
# Bash, 29 bytes

```
true&&false||false||a

```

error message:

```
a: command not found

```

it's really just filler of bash builtins before using an undefined command. This was the shortest bash error message I could think of.

# Answer
> 3 votes
# TRS-80 Model 100 Basic, 10 bytes

Enter this:

```
??????????

```

Resulting error message:

```
?SN Error

```

All Basic error codes on this charming little machine are retrieved by using the error code to index into an array in ROM that looks like `NFSNRG`... and so on, so all error codes must be exactly 2 characters. With the 7 extra characters taken into account, all error messages will always be 9 bytes and hence 10 bytes is the shortest possible on this machine.

This is just one way to do it; there are countless more. It generates error `2`, code `SN`, which means syntax error.

# Answer
> 3 votes
# C++ (on macOS High Sierra beta), 23 characters

```
int main(){*(int*)0=0;}

```

# Output: (22 characters)

```
Segmentation fault: 11

```

I do not recall whether previous versions of macOS provide the more traditional `Segmentation fault (core dumped)` response but adding spaces to the code to pad that out is pretty trivial.

# Answer
> 3 votes
# LibreOffice Calc, 7 bytes

```
=aaaaaa

```

Result:

```
#NAME?

```

# Answer
> 3 votes
# R, 9 bytes

\[edited, because I can't count to 8\]

code (9 bytes):

```
stop();;;

```

output (8 bytes, including trailing space and newline):

```
Error:

```

According to the manual, "`stop` stops execution of the current expression and executes an error action." The first argument is meant to be an error message, but can be omitted.

# Answer
> 3 votes
# BASIC (BBC micro) 9 bytes

```
>REN 9,-5
Silly.

```

# Answer
> 3 votes
# dc (GNU 1.2) on Windows 10 x64, 185 bytes

`dc` doesn't crash fatally very often, and I couldn't be bothered to remember code that causes a segfault. I did recall some weird behavior involving arrays that causes a sad and total loss of the current session.

```
zzz zzzzzzz zz zzzzz zzzzz zzzzzzzzzz

zzzz zzzzzzzzzzz zzz zzzzzzzzz zzz zzzzzzz zz zzzzzzzzz zz zz zz zzzzzzz zzzz
zzzzzz zzzzzzz zzz zzzzzzzzzzzzz zzzzzzz zzzz zzz zzzz zzzzzzzz:zlz

```

Pushes numbers on the stack until the last five characters. `:z` stores the second-to-topmost number in the topmost-indexed slot in the array named `z`. Typically, this array would be linked through time and space to the current instance in the register named `z`. However, we haven't actually put anything there. Next, we try to `lz`, or copy the value on top of `z` to the top of the main stack. We can't: there's nothing there. I'm not sure why this mechanism triggers the failure that it does, but it works. (Or...doesn't.) The trailing newline is significant for two reasons: it puts the code in the black at 185, and pasting it into `dc` causes it to crash immediately.

Basically, we're running across a canyon, and as long as we don't look down, we're good. But once we look and realize we're floating in mid-air, we fall and crash hard, and little stars zoom around our poor befuddled heads.

## Error, 184 bytes

```
dc: garbage in value being duplicated

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

```

I'm not sure if only part of that is the actual error or what, so feel free to correct me. The code is obviously very flexible when it comes to length.

# Answer
> 3 votes
### Sinclair ZX81 - 8 bytes 4 bytes 2 bytes (2 BASIC tokens) using direct mode:

Newest solution

```
 PRINT A

```

Less old solution

```
 PRINT A+A

```

Old solution (8 bytes of memory):

```
 1 PRINT A

```

When you enter the command `RUN`, the following error is reported:

```
2/1

```

as in the screen shot below - Error code 2 means "Undefined variable" or something similar.

# Answer
> 3 votes
# Shakespeare Programming Language, 48 bytes

```
,a.Ajax,a.Act I:a.Scene I:a.[Enter Ajax]I error!

```

Try it online!

Produces:

```
Unrecognized error encountered. No code output.

```

There's not much we can do about creating runtime errors, because the minimum overhead to create a program with two characters is 56 bytes, and you can't do much with one character. Instead, we settle for confusing the compiler, which means finding a sentence structure which doesn't fit the grammar rules. In this case, anything that isn't a character name after a character enters the stage.

Shorter error messages exist, for example `Error at line 1: act expected`, but the code compiled isn't valid, so you get an extra few lines of gibberish after the first error message.

# Answer
> 3 votes
# IE9 Chinese version, 9 bytes

```
'12345'()

```

Outputs (assuming GBK encoding)

```
缺少函数

```

# Answer
> 3 votes
# /bin/sh ("dash" on Ubuntu Bionic), 20 bytes

```
cd /;ok="okokokok";@

```

Output is:

```
sh: 1: @: not found

```

The `cd /` command it just to make sure to switch to a location where there isn't a file named `@` since that's effectively what causes the error.

# Answer
> 3 votes
# Vim, 17 bytes

```
            :w {

```

Try it online!

When you write to a file and you have an unmatched starting curly brace in the filename, it will give the error `E220: Missing }.` The code to get this error is very short, so we just pad it out with spaces to get to the length we want. You can't see this error on TIO, but it works in the terminal.

# Answer
> 3 votes
# Python 3, 29 Bytes

```
from __future__ import braces

```

## Error

```
SyntaxError: not a chance

```

# Answer
> 2 votes
# Brain-Flak, 46 bytes

```
))))))))))))))))))))))))))))))))))))))))))))))

```

Try it online!

This prints

```
Error at character 0: Unopened ')' character.

```

because in Brain-flak, all brackets must be balanced for the program to be valid.

# Answer
> 2 votes
# J, 10 bytes

```
0000000^.0

```

NaN error \<-------- length 9

# Answer
> 2 votes
# Japt, 32 bytes

```
????????????????????????????????

```

### Error message (31 bytes):

`SyntaxError: Unexpected token ?`

Try it online!

# Answer
> 2 votes
# Japt, 22 bytes

Dusting off the golfing cobwebs after a week's holidays; there's probably a shorter solution.

```
888888888888888888888z

```

Error:

```
No such function: N.z

```

Test it

# Answer
> 2 votes
# PHP, 56 bytes

```
<?php aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

```

produces

```
PHP Parse error:  syntax error, unexpected end of file

```

# Answer
> 2 votes
# Batch ~~90~~ 18 bytes

```
@set/ab=1+*2*3*4*5

```

`Missing Operand`\ Golfed by SteveFest

# Answer
> 2 votes
# Rexx (Regina), 25 bytes

```
interpret interpret 2+3+1

```

Try it online!

"interpret" treats the text following it as source and tries to execute it. Since 2+3+1 is not included in quotes it treats it as a calculation and does that first. Resulting in "interpret interpret 6" The first "interpret" tells REXX to treat "interpret 6" as source. So it executes it. This results in the attempt to execute 6 as source.

```
sh: 6: command not found

```

# Answer
> 2 votes
# C#, 46 bytes

```
class P{public static int Main(string[]arg){}}

```

And produces the error at 45 bytes:

> 'P.Main()': not all code paths return a value

Probably a shorter way to do this in C# but I can't think of it.

# Answer
> 2 votes
# Java 7, 43 bytes

Based on a comment from the OP, we are allowed to assume the filename is 1 character long. This program has that assumption and my example uses the source code's filename z.java

```
// public static void main(String[] args){}

```

Error message:

```
Error: Could not find or load main class z

```

# Answer
> 2 votes
## JAVA 8, 137 bytes error and 138 bytes code

```
package a;

public class a{
    public static void main(String[] args){
        String f = "sdfgsfdgdffffffffffffffffffffffffsfdgfd";
        a = 5;
    }
}

```

produces the error:

```
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
    a cannot be resolved to a variable

    at a.a.main(a.java:6)

```

as this is my first time please tell me if i did something wrong

# Answer
> 2 votes
# Shakespeare Programming Language, 73 bytes

```
Errors.
Ajax, the web technology.
Act XLII:;.
Scene LXIX:;.
Ajax:You cat.

```

Try it online!

# Error message, 72 bytes

```
Runtime error at line 7: Ajax is not on stage, and thus cannot speak!

```

with one leading and two trailing newlines. Not sure whether the newlines count.

# Answer
> 2 votes
# Eukleides, 17 bytes

Program:

```
a=centroid(empty)

```

Error:

```
X:1: empty set.

```

(Plus a newline). All fatal errors in Eukleides begin with `(filename):(line number):`  and end with a period and a newline. I combed the source, and found that `empty set` was the shortest error. At first, I thought I was out of luck, because I only saw the lengthy command `isobarycenter` throwing it, but spotted `centroid` throwing it as well. Then I couldn't figure out how to make an empty set; all my attempts got me a `syntax error` first. Turns out, `empty` is a constant for an empty set, something I never needed to know before. I am quite confident this is the shortest Eukleides solution.

# Answer
> 2 votes
# Octave, 28 bytes

```
a=[];'Will cause error';a(1)

```

Try it online!

This throws this error:

```
error: a(1): out of bound 0

```

**Damn, golfing error messages was cumbersome!** I have rewritten this answer 8 times now, since I've gradually found error messages that were one byte shorter than the previous one. I think this answer took me an hour, since I've made a complete rewrite 8 times... :(

---

Why is this the shortest error message?

* Relying on undefined functions or variables is not short enough (41)

```
 error: 'a' undefined near line 1 column 1

```
* Relying on the wrong input type is not short enough (38)

```
error: mod: wrong type argument 'sq_string'
error: whos: all arguments must be strings
error: sum: wrong type argument 'cell'

```
* Relying on syntax errors is definitely not short enough (42)

```
parse error:

  syntax error

>>> &
    ^

```
* Wrong indexing is not short enough (38)

```
error: scalar cannot be indexed with {

```
* Short function names and inputs that cause errors is not short enough (34)

```
error: a: No such file or directory
error: load: unable to find file a

```

I've looked through **all** the functions in Octave, and I can't imagine anything being shorter than this.

# Answer
> 2 votes
## , 29 bytes

```
Error: Unknown instruction E!

```

This tries to call the function E, which does not exist.

Output message:

```
Error: Unknown instruction E

```

# Answer
> 2 votes
# Rust, 61 57 bytes

```
fn main()->Result<(),usize>{[].binary_search(&0)?;Ok(())}

```

Try it online!

Returns from the main function with `Error: 0`.

-3 bytes thanks to Anders Kaesorg

# Answer
> 2 votes
## Red, 29 Bytes

```
a/1/1/1/1/1/1/1/1/1/1/1/1/1/1

```

```
Script Error: a has no value

```

# Answer
> 2 votes
# Shakespeare Programming Language, 100 bytes

```
,.Ajax,.Puck,.Act I:.Scene I:.[Enter Ajax and Puck]Ajax:You cat!You is the quotient betweenyou zero.

```

Try it online!

which produces

```
Runtime error at line 1: Unable to divide 1 by zero!

```

The error is 53 bytes including the trailing newline.

I really don't see how this can be improved (unless I missed something obvious). It loads 1 into Puck and attempts to divide him by 0.

# Answer
> 2 votes
# CPython 3.9, 71 bytes

```
__peg_parser__
########################################################

```

Not the shortest, but I found this "feature" worth sharing nonetheless: when Python 3.9 switched to a PEG parser, there was a special easter egg keyword `__peg_parser__` added which immediately causes a syntax error. The error outputted is:

```
  File "a", line 1
    __peg_parser__
    ^
SyntaxError: You found it!

```

This was removed in Python 3.10.

# Answer
> 1 votes
# Python 3, 67 bytes

<pre><code>`
  File ".code.tio", line 1
    ^`````
SyntaxError: invalid syntax
</code></pre>

Try it online!

### Error Message, 66 bytes

```
  File ".code.tio", line 1
    `
    ^
SyntaxError: invalid syntax

```

# Answer
> 1 votes
# Python 3, 71 bytes

```
a=b=c=d=e=f=g=h=i=j=k=l=m=n=o=p=q=r=s=t=u=v=w=x=y=z=A=B=C=D=E=F=1#
is=0

```

Try it online!

```
  File ".code.tio", line 2
    is=0
     ^
SyntaxError: invalid syntax

```

# Answer
> 1 votes
# Mathematica, 120 bytes

```
"Take it easy my brother JungHwan Min,Take it easy my brother LegionMammal978,Take it easy my brother Charlie"*666*666/0

```

> error-\> Power::infy: Infinite expression 1/0 encountered.

see comments for details...

# Answer
> 1 votes
# Bash, 20 bytes

```
"" # waste of space!

```

Outputs `: command not found`.

Try it online!

# Bash, 21 bytes

```
b # let's waste space

```

Outputs: `b: command not found`.

Try it online!

# Answer
> 1 votes
# Lua, 45 bytes

```
0/###########################################

```

Try it online!

# Error message, 44 bytes

```
lua: .code.tio:1: unexpected symbol near '0'

```

# Answer
> 1 votes
# Haystack, 21 bytes

```
Wasted space is good!

```

Errors with `Where's the needle?`. Dosen't work on TIO.

# Answer
> 1 votes
# C/\*nix, 13 bytes

```
f(){free(f);}

```

On minimalist/old systems and shells that don't do fancy things, this prints:

```
Aborted

```

Of course, most modern shells print things like:

```
*** Error in `/tmp/file': munmap_chunk(): invalid pointer: 0x0000000000400536 ***
Aborted

```

TryItOnline prints a whole host of information.

# Answer
> 1 votes
# 2Col, 50 bytes

```
Invalid code!
Line 0 contains invalid 2Col code!
1

```

Try it on 2ColIDE

Outputs:

```
Invalid code!
Line 0 contains invalid 2Col code!

```

With a trailing newline.

## Explanation

2Col only really has 1 error, and it's caused by the structure of the code being wrong. 2Col expects every line to be exactly 2 characters long, so if a line is longer or shorter than that, you get the above error.

Given that for this challenge the code must be longer than the error, the easiest way to achieve that is to use the error itself and add a byte.

# Answer
> 1 votes
# Casio Basic, 10 bytes

```
{}=>a:a[1]

```

or, for **12 bytes**:

```
seq(x,x,1,0)

```

**Error for both (6 bytes):**

```
Domain

```

For the first one, accessing a list element outside the length of the list throws a Domain error. But for some weird reason, you can't access a list index in one go; that is, `{}[1]` is invalid syntax.

`seq` generates a list of values for a function with values in a given range; but in this case, specifying a range of 1 to 0 causes a Domain error, since the end is smaller than the start.

# Answer
> 1 votes
# VBA, 29 Bytes

Anonymous VBE immediate window function of length 29 which throws Runtime error 6, (len 28) to STDERR

### Code

```
?CByte(Len(Space(127+128+1)))

```

### Error

> Run-time error '6':
>
> Overflow

# Answer
> 1 votes
# Braingolf, 54 bytes

```
"ZeroDivisionError: integer division or modulo by z"0/

```

Try it online!

Throws the 53 byte error `ZeroDivisionError: integer division or modulo by zero`

## Explanation

`"ZeroDivisionError: integer division or modulo by z"` is a string literal, pushes the error minus 3 bytes.

`0` pushes 0, and `/` attempts to divide the 2nd to last item by the last item, in this case dividing `z` (122) by `0`, which results in a divide by zero error.

# Braingolf, 84 bytes

```
"ValueError: Indices for islice() must be None or an integer: 0 <= x <= sys.maxs"&@@

```

Try it online!

I personally get this error quite often when screwing around with ASCII art challenges in Braingolf.

Throws a `ValueError: Indices for islice() must be None or an integer: 0 <= x <= sys.maxsize.` error.

## Explanation

`"ValueError: Indices for islice() must be None or an integer: 0 <= x <= sys.max"` is a string literal. It's just the error minus 4 bytes, because the code must be longer than the error.

`&@` then pops and prints the entire stack.

Finally `@` attempts to pop and print an item from the now empty stack. Popping from an empty stack produces the above 83 byte error.

# Answer
> 1 votes
# C++, 26 bytes

```
int main(){div(1,0);} //??

```

Result in Windows:

```
a.exe has stopped working

```

# Answer
> 1 votes
# Prolog (SWI), 26 bytes (error: 25 bytes)

```
a :- a ; a ; a ; a ; a ;a.

```

Try it online!

This will generate the error: `ERROR: Out of local stack` (which is, as far as I know, the shortest error message that can be generated by SWI-Prolog).

### Explanation

The above program can be simplified to `a :- a ; a.` (the other `; a`s are here so that the program is longer than the error message).

The above program says:

```
a :-      .        % For a to be true…
     a             % Either a…
       ;           % …or…
         a         % …a must be true

```

This is obviously infinitely recursive, hence why we get an `Out of local stack` error.

However, the following program:

```
a :- a.

```

is also infinitely recursive but will never crash. This is because in that case, **tail recursion optimization** occurs so that the recursive call does not consume memory.

`a :- a ; a.` is also tail recursive; however we have introduced a **disjunction** with `;` which prevents the recursive call from not consuming memory, because Prolog has to remember that there was another choice possible to explore instead of each recursive call.

---

It is possible to generate this same error with other approaches (e.g. using `length(_,1000000000)` to generate a list too big to fit in memory), but this one is probably the coolest looking one.

# Answer
> 1 votes
# Groovy, 69 bytes

```
java.lang.Class.metaClass=Integer.metaClass
Integer.metaClass.plus={1}

```

Error message is:

```
java.lang.StackOverflowError

```

I don't know if this will count at 31 bytes, because it will output a lot of line numbers:

```
aaaaaaa={aaaaaaa()};aaaaaaa()

```

Output:

```
java.lang.StackOverflowError
at Script1$_run_closure1.doCall(Script1.groovy:1)
at Script1$_run_closure1.doCall(Script1.groovy)
at Script1$_run_closure1.doCall(Script1.groovy:1)
at Script1$_run_closure1.doCall(Script1.groovy)
...

```

# Answer
> 1 votes
# MATLAB, ~~52~~ ~~44~~ 43 bytes

Another shorter option is to use a function and not provide enough inputs. For example:

```
qr()%I'm a nice comment to make code longer

```

Gives this 42 byte error:

```
Error using qr
Not enough input arguments.

```

---

This code (or to be fair any similar code:

```
[1 1]*[2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ]

```

Produces the following 51 byte error:

```
Error using  *
Inner matrix dimensions must agree.

```

It's actually surprisingly tricky in MATLAB because when you run any code with syntax errors the error output includes the line of code you ran - which would put a theoretical lower limit on code size of infinity. Fortunately matrix multiplication errors don't do that.

# Answer
> 1 votes
# C# (.Net, Mono) 25 bytes

```
class Hi{void There(){_}}

```

Error:

```
error CS1002: ; expected

```

**Note:** Mono error messages include filename and location before them, so if you named the file `P.cs`, you'd get this error:

```
P.cs(1,24): error CS1002: ; expected

```

Since that part depends on the filename and location of text, I didn't include it. However, if you include it (and make the class name longer or something), you end up with a 36 byte error message and 37 byte program. Let me know if I should change it to that.

# Answer
> 1 votes
# SmileBASIC console, ~~12~~ 11 bytes

```
?@L*EXP(22)

```

Error message (8 or 9 bytes):

```
Overflow

```

Must be run from the console, otherwise it outputs a line number. Normally errors are formatted like `{error} in {slot}:{line}({func}:{arg})`, but this error isn't caused by a function and doesn't have a line number so only the error name is shown.

`EXP(x)` returns `e^x`, and `e^22` is `3584912846.131588`. This is outside the 32 bit signed integer range of `-2147483648` to `2147483647`. Multiplying a string (`@L`) by this value converts it to an integer, causing an overflow error.

# Answer
> 1 votes
# Aceto, 41 bytes

```
                                        &

```

Try it online!

Produces `__main__.CodeException: Raised an &rror.`

The error message is 40 chars, so...

# Answer
> 1 votes
# ed, 3 bytes

```
?

```

Returns the following error message (2 bytes).

```
?

```

ed is Turing complete, so there shouldn't be issues about whether using it is valid or not. There was a solution in ed before, but it was removed, as there was a concern whether this is a fatal error. I would say, yes, it is, no matter what I did on TIO.run, the execution did not continue after getting an error message. From checking why this happens, it appears that the execution continues only when the code is read from STDIN (REPL mode).

Inspired by https://www.gnu.org/fun/jokes/ed-msg.html

Try it online!

Note that the output contains `0`, but it's not a part of an error message, rather it's ed displaying file size by default. It can be removed by using `-s` flag. If you try changing the input provided to the program, it will change.

# Answer
> 1 votes
# naz, 38 bytes

```
1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a4x

```

**Explanation**

```
1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a   # Add 1 to the register 18 times
                                    4x # Set the current opcode to 4

```

The only opcodes accepted by the naz interpreter under any circumstances are **0** (normal operation), **1** (function write), **2** (variable write), and **3** (conditional). Thus, if run from a file with a one-letter filename (e.g. `f.naz`), this program will produce the following 37-byte error:

```
error: invalid opcode
  at f.naz:1:38

```

# Answer
> 1 votes
# COBOL(GNU), 47 bytes

```
PROCEDURE DIVISION. HELLO. HELLO. HELLO. HELLO.

```

Outputs:

`main.cobc: 1: error: PROGRAM-ID header missing`

Assuming filename = main.cobc

# Answer
> 1 votes
# Setanta, 12 bytes

```
1/0 >--- uwu

```

This produces the 11-byte error message `Roinnt ar 0`.

Try it here

# Answer
> 0 votes
# Add++, 20 bytes

```
+?
Needed to be long

```

Try it online!

Error is `Error encountered!` followed by a newline, which is 19 bytes long. This happens because it tries to take input, but fails as there is no input.

# Answer
> 0 votes
# C++ 133 bytes

```
#include <iostream>
#include <cstdlib>

using namespace std;

int main(int argc, char *argv[]){
    printf("%s", variable);
    return 0;
}

```

Displays the error *(132 bytes)*:

> .code.tio.c: In function ‘main’: .code.tio.c:5:14: error: ‘variable’ undeclared (first use in this function) printf("%s", variable);

# Answer
> 0 votes
# Python 2, 67 bytes

```
b(h)#This has to be 67 characters. Thus, I'm writing this bullshit.

```

# Error message, 66 bytes

```
  File ".", line 1, in <module>
NameError: name 'b' is not defined

```

Note: doesn't work on TIO. Gives a longer error message. Try Python 2.7.13 on a local machine from stdin.

# Answer
> 0 votes
# Brain-Flak (BrainHack), 43 + 3 = 46 bytes

```
([()])()()()()()()()()()()()()()()()()()()-

```

Try it online!

Produces the error

```
BrainHack: Prelude.chr: bad argument: (-1)

```

# Answer
> 0 votes
# Zsh, 24 bytes

```
"" #lots of wasted space

```

Outputs `zsh: permission denied:`.

Try it online!

# Answer
> 0 votes
# Tcl/Tk, 19

```
pack [text .text 1]

```

outputs

# 18

```
unknown option "1"

```

# Answer
> 0 votes
## Batch, ~~24~~ 23 bytes

```
@dir                  /

```

Outputs the following ~~23~~ 22-byte error (as calculated by redirecting the output to a file):

```
Invalid switch - "".

```

Edit: Saved 1 byte by not having a switch character at all.

# Answer
> 0 votes
# Tcl, 15

```
if 1234567890/0

```

outputs

```
divide by zero

```

# Answer
> 0 votes
# Ly, 77 bytes

```
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[

```

Outputs:

```
Error occurred during parsing
SyntaxError: unmatched [] brackets in program

```

(note the trailing newline)

# Answer
> 0 votes
# Mathematica kernel, 36 bytes

```
ClearAll[f];(*Space Filler*)On[f::f]

```

and the error is 35 bytes:

```
(linebreak)On::none: Message f::f not found.(linebreak)

```

# Answer
> 0 votes
# , 14 bytes

```
3.141592653589

```

All `4` programs must start with `3.` and end with `4`.

Provides as error (when run with the provided python interpreter)

```
Code invalid.

```

# Answer
> 0 votes
# Applesoft BASIC, 14 bytes

```
SYNTAX ERROR??

```

Output:

```
?SYNTAX ERROR

```

# Answer
> 0 votes
# ExtraC, 21 bytes

```
Invalid character: :

```

Try it online!

If you remove the space after the second `:`it is a error quine

# Answer
> 0 votes
# Javascript 79 bytes

```
clear(this);
a=0;
typein:2: TyperError: attempt to run compile-and-go script on a

```

# Answer
> 0 votes
# C++ (MinGW + GCC + Windows), compile time, 38 ~~39~~ ~~46~~ bytes

According to OP's comment, it seems OK to assume the file is stored in a designated path. The code needs to be saved in a 8-byte location such as `D:\a.cpp`.

```
#if 1/*aaaaaaaaaaaaaaaaaaaaaaaaaaaaa*/

```

Error message:

```
D:\a.cpp:1:0: error: unterminated #if

```

The principle should work on other platforms.

# Answer
> 0 votes
# PHP, 47 Bytes

`<?php echo 'program including divide by 0',1/0;`

produces:

`PHP Warning: Division by zero in - on line 1` plus a newline.

# Answer
> 0 votes
# Vim, 19 bytes?

```
:print "ex command

```

With a trailing newline, this prints the current line to the messages window. If the buffer is empty, it shows `E749: empty buffer` instead. The `"` starts a comment.

I'm an very unsure how to count the number of bytes both in the input and error message. The command can be run as `vim +"print \"ex command"` (17 bytes?), but this adds an additional line to the error message: `Error detected while processing command line:` (total 62 bytes?).

Alternatively, the command can be put in a file and run the the following hack to trick Vim it is user input: `cat cmd.vim - | vim --not-a-term`. Without `--not-a-term` Vim writes `Vim: Warning: Input is not from a terminal`.

I didn't count the error message length including a newline since Vim won't write a newline to the screen; it uses ncurses or similar to directly draw at specific coordinates.

There is one potentially shorter error message: `E572: Exit code %d`. It can be triggered by `:tcl`, but I'll leave it to someone who has `+tcl` enabled.

# Answer
> 0 votes
# \>\<\>, 26 Bytes

Code: `"we'refinehereuntilthis!"z`

Error: `Something smells fishy...`

All \>\<\> errors are Something smells fishy...

# Answer
> 0 votes
# JavaScript, 13 bytes

```
prompt(alert(

```

Error produced (12 bytes):

```
Expected ')'

```

# Answer
> 0 votes
# Julia 0.6 (REPL/-e), 20 bytes

```
print(factorial(-9))

```

produces:

```
ERROR: DomainError:

```

(assuming stacktraces don't count) which is 19 bytes.

---

Older answer, 22 bytes:

```
println(Int(Inf)+0123)

```

Produces

```
ERROR: InexactError()

```

which is 21 bytes.

---

Trivial answer, 7 bytes (probably falls short of "The error message may not be generated by the program itself, such as Python's raise" requirement):

```
error()

```

produces

```
ERROR:

```

# Answer
> 0 votes
# Attache, 40 bytes

```
A Reference Error: Undefined variable!!!

```

Try it online!

Message (39 bytes): `Reference Error: Undefined variable "A"`

# Answer
> 0 votes
# F#, 29 bytes code, 28 bytes error message

```
let [<EntryPoint>] main a=1/0

```

Generates the runtime Exception message:

```
Attempted to divide by zero.

```

+5 bytes thanks to lukass.

# Answer
> 0 votes
# Go, 36 bytes

```
package verylongnamednonmainpackage;

```

Produces:

```
go run: cannot run non-main package

```

# Answer
> 0 votes
# Coconut, 48 bytes

Code:

```
+
CoconutParsererErrorr: parsing failed (line 1)

```

Prints error (47 bytes):

```
CoconutParseError: parsing failed (line 1)
  +

```

with a trailing newline

Try it online!

# Answer
> 0 votes
# Loader, 50 bytes

```
load t
This is line not executed because of error.

```

Assumptions:

* The program is run from a file with a one-byte name
* The module named `t` does not exist.

The error message (assuming you run from a module named `m`) is:

```
Error: module t does not exist (module m, line 1)

```

# Answer
> 0 votes
# C# .NET, 59 bytes

```
public class P{static void Main(){int je=0;int iee=je/je;}}

```

Try Online
Produces the following error (58 bytes):

```
System.DivideByZeroException: Attempted to divide by zero.

```

(**NOTE:** I am not counting in the stacktrace that the .NET Compiler generates)

# Answer
> 0 votes
## Python, 30 bytes

```
import math as ma; ma.sqrt(-1)

```

Error: `ValueError: math domain error` (29 bytes)

# Answer
> 0 votes
# GNU Smalltalk, 26 bytes

Create a source file `_` with underscores:

```
__________________________

```

Running `gst _`, the error is 25 bytes including ␤:

```
_:1: expected expression

```

Underscore was originally mapped to , the assignment operator prior to `:=`.

# Answer
> 0 votes
## C, Bionic libc (Android, Termux), 16 characters

```
main(){free(1);}

```

## Output, 8 characters (including newline)

```
Aborted

```

# Answer
> 0 votes
# Python, 35 bytes

Pretty simple.

```
print(a)###########################

```

Prints out an undeclared variable then adds a comment to make sure that the error message (`NameError: name 'a' is not defined`) is shorter than the actual code. I could've probably done better.

# Answer
> 0 votes
# Whitespace (wspace 0.3), 19 bytes

```
SSSSL
SLS
TSTS
TLST
LLL

```

Error: `w: divide by zero` (18 bytes)

Try it online!

The zero divisor error is the shortest error message produced by the wspace 0.3 reference interpreter (see the yspace project for a survey of other errors). Using `mod` in place of `div` would yield an equivalent result. The reference interpreter was written in Haskell, so arithmetic operations are evaluated lazily and it will not panic with `divide by zero` unless the illegal value is used by an eager instruction—`printi` in this case. To reach the minimum byte count, `push 0` is written as `SSSSL` and `end` is appended.

```
push 0
dup
div
printi
end

```

Renaming `wspace` to `w` gives a shorter error message.

```
$ ln -s ~/bin/wspace w
$ ./w codegolf/shortest_error.ws
w: divide by zero
$ ./w shortest_error.ws 2>| wc -c
      18
$ wc -c < shortest_error.ws
      19

```

*(This solution is part of the ws-challenges repo)*

# Answer
> 0 votes
# Raku (Perl 6) (rakudo), 38 bytes

```
die#iaj zav; xbsio la, n v km l s zioa

```

When run using `raku -e`, this produces the 37-byte output

```
Died
  in block <unit> at -e line 1

```

Attempt This Online!

# Answer
> 0 votes
# Vyxal 3, 38 bytes

```
222222222222222222222222222222222222[x

```

Try it Online!

RuntimeException: Too many recursions

# Answer
> 0 votes
# YASEPL, 38 bytes

```
=p/0+000000000000000000000000000000000

```

error message:

```
ERROR 8 divide by 0:(

located at /0

```

# Answer
> 0 votes
# Go, 67 bytes

```
package main
func main(){var f string = "aaaaaaaaaaaaaaaaaaaaaaaa"}

```

Attempt This Online!

Gives the following error (66 bytes):

```
# command-line-arguments
../code.go:2:17: f declared and not used

```

# Answer
> 0 votes
# Swift, 46 bytes

```
let message = "what do you want it to do?"
let

```

Try the fiddle!

## Error, 45 bytes (when compiled from standard input)

```
<stdin>:2:4: error: expected pattern
let
   ^

```

---
Tags: code-golf, error-message
---


title: The alphabet in programming languages

text:
# Question
Title: The alphabet in programming languages
Our task is to, for each letter of the (English) alphabet, write a program that prints the alphabet, in a language whose *name* starts with that letter.

**Input:** *none*

**Output:**

```
abcdefghijklmnopqrstuvwxyz

```

*uppercase and trailing newline optional*

**Rules**:

* The scoring metric is the length of the programming language *name*, **plus** the length of the code. Hence, C will be assessed a "penalty" of 1, while GolfScript will be assessed a penalty of 10.
* One language/implementation per answer. Multiple answers are encouraged.
* If a programming language name's first letter is not an English letter, it should not be coerced into one. It will be treated as a separate letter (meaning less competition).
* No answer will be accepted until every English letter has a solution.

---

Current rankings:

Tell me if I'm missing anybody.

## Automatic leaderboard (experimental)

```
var QUESTION_ID=2078;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&r.indexOf('non-competing')===-1&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],lang:/<a/.test(a[1])?jQuery(a[1]).text():a[1],link:s.share_link})}),e.sort(function(e,s){var d=e.lang[0].toLowerCase(),a=s.lang[0].toLowerCase();return(d>a)-(d<a)||e.size-s.size});var s={},a=null,n="A";e.forEach(function(e){n=e.lang[0].toUpperCase(),a=e.size;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+" is for").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.lang,p=o[0].toUpperCase();s[p]=s[p]||{language:e.language,lang:e.lang,letter:p,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return(e.letter>s.letter)-(e.letter<s.letter)});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.language).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),jQuery("#languages").append(jQuery(i))}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*(?:<[^>]+>)?(?:[^]+?for )?((?:<a[^>]*?>)?(?:(?! [(=→-])[^\n,:])*[^\s,:])(?:[,:]| [(=→-]).*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
```

```
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px} /* font fix */ body {font-family: Arial,"Helvetica Neue",Helvetica,sans-serif;} /* #language-list x-pos fix */ #answer-list {margin-right: 200px;}
```

```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Winners by Letter</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <h2>Everything</h2> <table class="answer-list"> <thead> <tr><td></td><td>Language</td><td>Author</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>
```

# Answer
# K is for , 12 characters -\> Score: 13

```
`0:_ci97+!26

```
> 14 votes

# Answer
# P is (actually) for Piet \- 57 codels

Large version (codel size = 6)

Small version (codel size = 1)

Tested with Erik's piet interpreter `npiet` and developed with Piet Creator.

**Edit**: Here is a "trace" version (generated with `npiet -tpf`) so you can see how it works.

Execution starts in the top left and goes around the border clockwise. The top edge and right edge are setup (calculating the value of `a` (97) takes quite a few codels). The loop starts on the bottom edge and goes to the left edge. When the value of `z` is reached the program turns right into the cross section under the first `P` and terminates.

Click the image to enlarge and see details
> 26 votes

# Answer
## P is for Perl, 10 characters -\> Score: 14

```
print a..z

```
> 17 votes

# Answer
## P is for Python 2, 29 chars -\> Score: 35

Every few years I come here with an update. See below.

Also I'm proposing the addition of range expressions to Python over here with demo code here. That would allow us to make an even more compact answer.

## Mar 2023: 29 chars

I realize the question says the output can be uppercase which allows us to shave off another char. It is quite ridiculous I didn't see that before.

```
print bytearray(range(65,91))

```

## Nov 2019: 30 chars

I did it, after 8 years I realized there is a shorter way in python 2!

```
print bytearray(range(97,123))

```

Previous code that was as big as trivial print:

## Jul 2011: 33 chars

```
print'%c'*26%tuple(range(97,123))

print'abcdefghijklmnopqrstuvwxyz'

```

Edit: Check out the breakthrough with Python 3 where I also found a solution smaller than trivial print: https://codegolf.stackexchange.com/a/195165/2212
> 15 votes

# Answer
## Y is for Yoix, 44 characters → Score: 48

```
int x;for(;++x<27;)yoix.stdio.putchar(96+x);

```
> 14 votes

# Answer
## W is for Whitespace, 72 characters -\> Score: 82

```
[Sp][Sp][Sp][Tab][Tab][Sp][Sp][Sp][Sp][Tab][LF][LF][Sp][Sp][Tab][Tab][LF][Sp][LF][Sp][Tab][LF][Sp][Sp][Sp][Sp][Sp][Tab][LF][Tab][Sp][Sp][Sp][Sp][LF][Sp][Sp][Sp][Sp][Tab][Tab][Tab][Tab][Sp][Tab][Tab][LF][Tab][Sp][Sp][Tab][LF][Tab][Sp][Sp][Sp][LF][LF][Sp][LF][Tab][Tab][LF][LF][Sp][Sp][Sp][Sp][LF][LF][LF][LF]

```

I spent ages getting this stupid thing to work last night and then found that whitespace doesn't show as code here! Then, while I was sulking, my Internet connection died. So, I'm posting it now just so I didn't waste an hour of my life last night getting it to work.
> 13 votes

# Answer
## A is for APL,  ~~14~~  11 chars/bytes\* → score 14

```
⎕UCS 96+⍳26

```

This works at least in Dyalog and Nars2000.

---

* APL can be written in its own (legacy) single-byte charset that maps APL symbols to the upper 128 byte values. Therefore, for the purpose of scoring, a program of N chars *that only uses ASCII characters and APL symbols* can be considered to be N bytes long.
> 11 votes

# Answer
## G is for Golfscript, 8 characters -\> Score: 18

```
123,97>+

```
> 10 votes

# Answer
## R is for R, 19 → Score: 20

```
cat(letters,sep="")

```
> 10 votes

# Answer
## R is for Ruby, 13 characters -\> Score: 17

A Ruby 1.9 solution Matma Rex came up with:

```
print *?a..?z

```

My original Ruby 1.8 solution (15 characters -\> Score: 19):

```
$><<[*'a'..'z']

```
> 7 votes

# Answer
# D is for dc, 17 characters → Score: 19

```
97[dP1+dBD>x]dsxx

```
> 7 votes

# Answer
## F is for Fish (\>\<\>), 19 chars -\> Score: 23

Because it's a damn beautiful language!

```
30"`"1+::o&p&"y"(?;

```
> 7 votes

# Answer
## S is for Scala, 16 chars =\> score 21

```
'a'to'z'mkString

```

18 chars =\> score 23

```
'a'to'z'mkString""

```

22 chars =\> score 27

```
('a'to'z')map(print _)

```
> 6 votes

# Answer
## C is for C, ~~36~~ 35 characters → Score: 36

```
main(a){for(;putchar(a+++64)-90;);}

```
> 6 votes

# Answer
# O is for Owl, 11 characters -\> Score: 14

```
a[%)1+%z>]!

```
> 6 votes

# Answer
## P is for Python 2, 42 characters → Score: 48

```
import string
print string.ascii_lowercase

```
> 6 votes

# Answer
# B is for Befunge → 18 characters

```
"a"::,1+10p"y"`#@_

```
> 6 votes

# Answer
## P is for PowerShell, 15 characters → Score: 25

```
-join('a'..'z')

```
> 5 votes

# Answer
## L is for Logo, 26 characters → Score: 30

```
for[i 97 122][type char i]

```
> 5 votes

# Answer
## P is for Python 2, 41 characters → Score: 47

```
print''.join(chr(i+97)for i in range(26))

```
> 5 votes

# Answer
## B is for bc \- 2 + 28 = 30

```
"abcdefghijklmnopqrstuvwxyz"

```
> 4 votes

# Answer
# J is for J, 14 characters -\> Score: 15

```
echo u:97+i.26

```
> 4 votes

# Answer
## B is for Bash: 4 + 16 = 20

```
printf %s {a..z}

```

or 15 with just:

```
echo {a..z}

```

if output of the form `a b c ...` is allowed (as seen in many other answers).
> 4 votes

# Answer
## T is for Thue, 35 characters → Score: 39

```
0::=~abcdefghijklmnopqrstuvwxyz
::=
0

```
> 4 votes

# Answer
## M for Matlab, 13 chars, Score 19

```
disp('a':'z')

```

M for Matlab, 18 chars, Score 24

```
disp(char(97:122))

```
> 4 votes

# Answer
## A is for AppleScript, 41 -\> Score: 52

```
display alert"abcdefghijklmnopqrstuvwxyz"

```
> 4 votes

# Answer
# B is for BrainF\***, 38 + 9 = 47

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

```

Can be reduced to **31+9 = 40**, if cells wrap around at 256:

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

```
> 4 votes

# Answer
## I is for Inform 6, 41 + 6 = 47

```
[Main i;for(i=26:i--:)print(char)'z'-i;];

```
> 3 votes

# Answer
## U is for Unlambda \- 8 + 79 = 87

``````````````````````````.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.zr

> 3 votes

# Answer
## Q is for QBasic, 29 characters → Score: 35

```
?"abcdefghijklmnopqrstuvwxyz"

```

Untested, but programming is like riding a bike, right?
> 3 votes

# Answer
## H is for Haskell, 21 characters → Score: 28

```
main=putStr['a'..'z']

```
> 3 votes

# Answer
## S is for Scheme, 37 -\> Score: 43

```
(display"abcdefghijklmnopqrstuvwxyz")

```
> 3 votes

# Answer
**L is for LUA: 3 + 40 = 43**

```
repeat n=1+(n or 96)print(("%c"):format(n))until(n>122)

```

-\> 55

```
repeat n=1+(n or 96)print(string.char(n))until(n>122)

```

-\> 53

```
for i=97,122 do print(string.char(i))end

```

-\> 40
> 3 votes

# Answer
# G is for GP, 30 characters -\> score 32

```
Strchr(vectorsmall(26,i,96+i))

```

If I stole the 36-character C code I could submit it as a score-40 submission for PARI -- though maybe at that point I'd be required to `#include <pari/pari.h>` at the painful cost of an additional 23 characters.

I'm too embarrassed to submit

```
"abcdefghijklmnopqrstuvwxyz"

```

which would be printed in gp.
> 3 votes

# Answer
# I is for International Phonetic Esoteric Language (IPEL), 19 bytes + 4 characters = 23 score

```
{97}{q}0ɑbesχue1søɒ

```

Score ~~can be~~ is 24 ~~if~~ since IPEL is acceptable.

## Explanation

```
{97}{q}0ɑbesχue1søɒ
{97}                (push ord of "a")
    {q}0            (push loop bounds: 0 to 26. Q == 26 in base36)
        ɑ           (start loop)
         besχu      (print chr[65+index])
              e1sø  (increment index)
                  ɒ (end loop)

```

---

# I is for International Phonetic Esoteric Language (IPEL), 20 bytes + ~~40~~ 4 characters = ~~60~~ 24 score

```
{97}{26}0ɑbesχue1søɒ

```
> 3 votes

# Answer
## PHP, 26 characters -\> Score: 29

```
abcdefghijklmnopqrstuvwxyz

```
> 2 votes

# Answer
## P is for PostScript, 29 chars → Score: 39

```
(abcdefghijklmnopqrstuvwxyz)=

```
> 2 votes

# Answer
## B, 45 -\> Score: 46

```
main(){auto i;i=95;while(i++<122)putchar(i);}

```
> 2 votes

# Answer
## m4, 26 characters -\> Score: 28

```
abcdefghijklmnopqrstuvwxyz

```

(Hey, shinh lists it as a supported language)
> 2 votes

# Answer
# Xtal, 31 characters -\> Score: 35

```
"abcdefghijklmnopqrstuvwxyz".p;

```
> 2 votes

# Answer
## , 28 characters → Score: 29

```
for x in 0..25{print('a'+x)}

```
> 2 votes

# Answer
# N is for newLISP, 35 characters -\> Score: 42

```
(print"abcdefghijklmnopqrstuvwxyz")

```
> 2 votes

# Answer
# Z is for zsh, 31 characters -\> Score: 38

```
echo abcdefghijklmnopqrstuvwxyz

```
> 2 votes

# Answer
## L#, 28 characters → Score: 30

```
"abcdefghijklmnopqrstuvwxyz"

```
> 2 votes

# Answer
# F is for False, 17 characters -\> Score: 22

```
97[$123\>][$,1+]#

```
> 2 votes

# Answer
## A is for awk: 37 characters -\> score 40

```
BEGIN{for(i=96;i++<122;)printf"%c",i}

```
> 2 votes

# Answer
## U is for Unicon, 50 + 6 = 56

```
procedure main();every writes(char(97 to 122));end

```
> 2 votes

# Answer
## c,34 characaters -\> score : 35

```
main(a){for(;a++<27;putch(95+a));}

```
> 2 votes

# Answer
## G is for Groovy, 25 -\> Score: 31

```
('a'..'z').each{print it}

```
> 2 votes

# Answer
# V is for VBA - 43 (40+3) or 32 (29+3)

(formatted to run in the immediate window)

**40 chars**

```
For b=65 To 90:c=c & Chr(b):Next:Print c

```

And shorter, but no thinking involved:

**29 chars**

```
?"abcdefghijklmnopqrstuvwxyz"

```
> 2 votes

# Answer
**Forth, 29 + 5 Score: 34**

```
: a 123 97 do i emit loop ; a

```

**Previous (Forth, 48 + 5 Score: 53 (unclean score = 48))**

```
: a 97 begin dup emit 1 + dup 123 = until drop ;

```

This is the clean version.

```
: a 97 begin dup emit 1 + dup 123 = until ;

```

The second one leaves stuff on the stack.

```
a
abcdefghijklmnopqrstuvwxyz  ok

```
> 2 votes

# Answer
**C++, 32 + 3penalty = 35**

I could not find C++. So this is my option for it:

```
char a=96;while(a++<122)cout<<a;

```

the output is:

```
abcdefghijklmnopqrstuvwxyz

```

PS. It's my first golf, pls comment if i did something wrong
> 2 votes

# Answer
# A is for APL, 9 characters → Score: 12

```
17↓43↑⎕av

```

Take the first 43 characters from `⎕av`, then drop the first 17 of those.

(Tested in Dyalog APL)
> 2 votes

# Answer
# brainfuck, 60 -\> 69

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

```

Try it online!

-2 bytes thanks to Dust
> 2 votes

# Answer
# A is for APL, 2 → 5

```
⎕a

```

Works on MicroAPL's APLX.
> 2 votes

# Answer
## V is for Vim, 9+3 → Score: 12

```
:h<_<CR>LY<C-^>P

```

The screen must be exactly 66 characters wide, and 8 lines high. You can check this with `tput cols` and `tput lines`.

The program should be executed with:

```
echo>file.txt && /bin/vim -u NONE $'+normal :h<_\xALYZQP' '+wq' file.txt && cat file.txt

```

As discussed in this vim scoring meta post
> 2 votes

# Answer
# L is for Lua, 49 bytes → Score: 52

Previous answer for Lua had each letter printed on a new line. All on one line:

```
s=""for i=97,122 do s=s..("").char(i)end print(s)

```

Try it online!
> 2 votes

# Answer
# B is for Brainfuck, 42 Bytes + 9 = Score 51

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

```

## Ungolfed and commented

```
+++++++++[>+++++++++++>+++<<-]  Leaves the tape with the values 99 and 27.
>--                             Subtracts 2 from 99 to make 97, the ASCII Code for an "a".
>-                              Subtracts 1 from 27 to make 26, the number of letters in the alphabet.
[-<.+>]                         Outputs the letter, adds 1 and decrements from the number of letters remaining.
                                When no letters are remaining, the loop Exits.

```
> 2 votes

# Answer
# B is for brainfuck, ~~32~~ 31 + 9 = 40

-1 byte thanks to Jo King

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

```

Try it online!

`-[>++>+<<-----]>` is derived from the initialization part for 51 and generates the following layout: `102|51`. The next part `>----->+` changes this to `97|52` where `52` is double the amount of letters in the alphabet and `97` is the charcode of `a`. The final loop `[<.+>--]` prints a letter and increments the charcode and decrements the counter twice.
> 2 votes

# Answer
# B is for Brachylog, 2 bytes → Score: 11

```
Ạẉ

```

Try it online!
> 2 votes

# Answer
# C is for Cubix, 15 bytes, Score -\> 20

```
uo)U"z`"-?@./;/

```

Try it online!

Cubified

```
    u o
    ) U
" z ` " - ? @ .
/ ; / . . . . .
    . .
    . .

```

Watch it run
> 2 votes

# Answer
# X is for x86, 9 bytes + 3 -\> score 12

(or "x86 machine code" for 9 + 16 = 25)

```
b0 61 aa 40 3c 7a 76 fa  c3

```

This is a function, callable with `void alpha(char edi[26])`, like the x86-64 System V calling convention but in 32-bit mode. Or 16-bit mode (where `40` decodes as `inc ax`, otherwise the same).

**The question says "program" that "prints"**, and this is neither of those things. I'm not sure this should count. Making a DOS .com executable out of this would take a few extra bytes, or the `.text` section of a Linux executable, including print and exit system calls. But there are several other answers (like some C++ ones) that are merely snippets that wouldn't even compile without `#include<iostream>` and `int main(){`.

I'm just going to follow modern codegolf defaults for I/O methods (Default for Code Golf: Input/Output methods) which include returning a string in the caller's buffer.

---

An x86-64 version would cost 1 extra byte for `inc al` or `inc eax`, and 3 extra characters in the language name. I could call it x64 but that implies Windows where the standard calling convention doesn't use RDI. But that's irrelevant, this is an asm / machine-code answer which doesn't care about being called from other languages. So anyway, I could say "x64" for a 10 + 3 = 13 version, but I hate that name because it goes with using "x86" to mean specifically 32-bit, instead of the whole ISA.

Ungolfed:

```
                machine code     NASM/FASM source
     1                         alpha:
     2 00000000 B061               mov  al, 'a'
     3                         .loop:               ; do {
     4 00000002 AA                 stosb              ; *edi++ = al
     5 00000003 40                 inc  eax           ; more compact than inc al
     6 00000004 3C7A               cmp  al, 'z'
     7 00000006 76FA               jbe  .loop       ; }while(al<='z')
     8 00000008 C3                 ret

```

Try it online! with a FASM `_start` caller.

---

**Justification**: "x86 machine code" is as much a description as a name. Machine code is something you can program in and can be considered a family of languages. But those languages don't usually have names other than the ISA. I'd usually say "x86 32-bit machine code" when posting an answer like this, but that's just to make it clear the answer is the machine code, not the asm source text in the same listing.

Out of all ISAs, x86 is clearly recognizable as the name of this one. It's not a language that people regularly program in *directly*; usually we generate it from assembly language (or higher level languages).

"IA" (Intel Architecture) or "IA-32" are other common names for the ISA, so I could argue for a score of 11 in the letter "I". (But the only "x" answer is xtal at 35, so posting this as x86 is a more useful answer for reducing the total sum length across all letters.

Of course "x86" can be considered ambiguous between the machine code and assembly language. And without context it's not obviously a programming language because it's better known as the name of an ISA.
> 2 votes

# Answer
# K is for Keg, 3 + 3 bytes - \> 6

```
azɧ

```

Try it online!

It *seems* that the rule disallowing newer languages to be posted has been removed. Let me know if this is somehow invalid.
> 2 votes

# Answer
# T is for Triangular, 19 bytes → 19+10 = 29

```
,5,D@"*i.jC>"dj>F+/

```

Try it online!

Ungolfed:

```
     ,
    5 ,
   D @ "
  * i . j
 C > " d j
> F + /

```

The process here is,

* Push 65
* Push 27
* `j` is a conditional NorthWest IP switch; it changes to NW if the top value of the stack is not 0. This means we have the equivalent of looping from 26 to 0 (because we decrement prior to entering the loop)
* Decrement → `j` → Swap top 2 stack values → Print, don't pop → Increment → Swap → Repeat

This turns out to be 1 byte shorter with capital letters than lower case due to 97 being prime.
> 2 votes

# Answer
## P is for Python 3, 32 chars -\> Score: 38

```
print('%c'*26%(*range(97,123),))

```

Using uppercase letters, this can be made shorter

```
print('%c'*26%(*range(65,91),))

```

This is based in my 2011 answer which is before Python 3.5 added starred tuple unpacking, making it smaller that that one....

EXCEPT for Python 2 also got a smaller version today which is unbeatable :)

Unless Python adds range expressions to the language, which I am proposing here
> 2 votes

# Answer
# M is for MAWP, 20 characters - Score: 24

```
[!43W8WM;1M!93WA?.%]

```

Explanation:

```
[        start of loop
!        duplicate top of stack
43W8W    push 96 to stack (4*3*8)
M        add 96 to number below
;        output top of stack as ASCII char
1M       add 1 to top of stack
!        duplicate top of stack
93W      push 27 to stack (9*3)
A        Difference of top two stack values
?.       is equal to zero, then terminate program
%        pop top of stack
]        end of loop

```
> 2 votes

# Answer
### **X is for x86-16 MS-DOS machine code - 16 bytes**

This is hexdump from `.COM` file :

```
00000000  b4 02 b9 1a 00 b7 61 8a  d7 cd 21 fe c7 e2 f8 cd  |......a...!.....|
00000010  20                                                | |
00000011

```

Code I wrote :

```
.model small
.code
org 100h

start:

    mov ah, 02h
    mov cx, 26
    mov bh, 97

.loop:
    mov dl, bh
    int 21h
    inc bh
    loop .loop
    int 20h

end start

```

I use DOSBOX to run this proram
> 2 votes

# Answer
## B is for Batch File, 31 characters → Score: 41

```
echo abcdefghijklmnopqrstuvwxyz

```
> 1 votes

# Answer
## Ada, 92 characters -\> Score: 95

```
with ada.text_io;use ada.text_io;procedure a is begin put("abcdefghijklmnopqrstuvwxyz");end;

```
> 1 votes

# Answer
## F is for F#, 36 characters -\> Score: 38

```
printf("abcdefghijklmnopqrstuvwxyz")

```
> 1 votes

# Answer
# Tcl - 31 + 3 = 34

```
puts abcdefghijklmnopqrstuvwxyz

```
> 1 votes

# Answer
# Wake, 33 bytes, score 37

```
all: "abcdefghijklmnopqrstuvwxyz"

```
> 1 votes

# Answer
## , 26 characters → Score: 27

```
for x in'a'..'z'{print(x)}

```

*This is based off Joey's answer.*
> 1 votes

# Answer
# Python, 36 + 6 = 42

```
print''.join(map(chr,range(97,123)))

```

Not the shortest...
> 1 votes

# Answer
## P is for PHP - 33 characters - Score: 36

```
echo implode("",range("a", "z"));

```
> 1 votes

# Answer
**V for VBA: 60**

```
Sub VforVBA()
For i=1 To 26: a=a & Chr(64+i): Next: Debug.Print a
End Sub

```
> 1 votes

# Answer
## C++: 32+3 = 35

```
char c=96;while(c++<122)cout<<c;

```
> 1 votes

# Answer
## C is for Clojure - (39 or 53) + 7 = 46 or 60

No, it doesn't stand for C. In Clojure, all functions form closures, so I would argue this is a complete answer, in 39 bytes.

```
(doseq[c(range 97 123)](print(char c)))

```

But if you really want it with the main function, 53 bytes.

```
(defn -main[](doseq[c(range 97 123)](print(char c))))

```

But, this isn't a Clojuric way to solve this problem. Let's try something simpler (could be golfed for 4 bytes).

```
(print (apply str (map char (range 97 123))))

```

Much better, isn't it?
> 1 votes

# Answer
# U is for Unix Shell, 21 Characters → Score: 31

```
echo {a..z}|tr -d " "

```
> 1 votes

# Answer
# V is for VBScript, 40 Characters → Score: 48

```
for i=97 to 122:a=a+chr(i):next:MsgBox a

```
> 1 votes

# Answer
# P is, in fact, for PHP - 23 chars / 27 score

```
<?=join('',range(a,z));

```
> 1 votes

# Answer
# N is for Nu, 35 Characters → Score: 37

```
(puts 'abcdefghijklmnopqrstuvwxyz')

```
> 1 votes

# Answer
# N is for Nim, 31 → Score: 34

```
for x in'a'..'z':stdout.write x

```
> 1 votes

# Answer
## S is for SMBF, 10 chars -\> Score: 14

SMBF stands for Self-modifying Brainf\***, and both names are used interchangeably. The original interpreters were named `smbf.c` and `smbf.rb`.

`\x1a` is a hex literal (a single non-printable ASCII character) for the decimal number 26.

```
<[-<.+>]a\x1a

```

The `\x1a` is used as a loop counter. `a` is printed and incremented each time.
> 1 votes

# Answer
# B is for Bash, 11 -\> ~~15~~ 24

~~```
echo {a..z}
```~~
```
echo {a..z}|tr -d \
                   ^
                 space

```
> 1 votes

# Answer
# Mouse, 26 + 5 = 31

```
97a:(a.123<^a.&DUP !'1+a:)

```

Which outputs:

```
abcdefghijklmnopqrstuvwxyz

```

Note the lame way would be:

```
"abcdefghijklmnopqrstuvwxyz"

```

Which gets printed implicitly immediately (as string literals do, unfortunately), but it's 28 bytes.
> 1 votes

# Answer
# J is for Java - score: 84 characters + 4 = 88

```
interface a{static void main(String[]A){for(char c=65;c<91;System.out.print(c++));}}

```

This prints `ABCDEFGHIJKLMNOPQRSTUVWXYZ` instead of `abcdefghijklmnopqrstuvwxyz`. If it's disallowed, one can simply set `c` to 97 (`a`) and loop until it reaches 123 (`{`) at the cost of one extra byte:

```
interface a{static void main(String[]A){for(char c=97;c<123;System.out.print(c++));}}

```
> 1 votes

# Answer
## S is for seed7, ~~137~~ ~~114~~ 78 characters → Score: 83

```
const proc: main is func begin writeln("abcdefghijklmnopqrstuvwxyz");end func;

```
> 1 votes

# Answer
# F is for Funge → 19 chars + 5 = 24

```
'\`#;1+::,"@9"+\`#@_;

```

Something that makes this **unique is that it doesn't contain a single letter of the alphabet!** Hence why I didn't shorten it by replacing `"@9"+` with `'y`. I'll take the points hit for it.

Try it with my interpreter here: BefungeSharp.
> 1 votes

# Answer
## D is for D2, 2 + 6 = 8

```
!a[.+]

```

`!a` expand to 10 `+`, setting the current cell to `10` (`a` in base 36), and `[.+]` print the current cell as a base 36 string and increment the cell. Since the maximum value a cell can hold is 35, at 36 the cell is zeroed and the loop stop.
> 1 votes

# Answer
# S is for Swift, 76 characters -\> Score: 81

```
var s=""
for i in 97...122{s.append((Character(UnicodeScalar(i))))}
print(s)

```
> 1 votes

# Answer
## R, 26 bytes (score 27)

```
paste(letters,collapse="")

```

Output:

```
[1] "abcdefghijklmnopqrstuvwxyz"

```
> 1 votes

# Answer
# S is for SmileBASIC, ~~39~~ 37 bytes

```
FOR I=65TO 90?CHR$(I);:NEXT

```
> 1 votes

# Answer
# Y is for Yorick, 30+6 bytes → 36

```
system,"echo {a..z}|tr -d ' '"

```
> 1 votes

# Answer
# Z is for Zsh, 21+3 → 24 bytes

```
echo {a..z}|tr -d ' '

```

Try It Online!
> 1 votes

# Answer
# R is for , 17 bytes Score -\> 18

```
intToUtf8(97:122)

```

Try it online!
> 1 votes

# Answer
## M is for M, 20 characters → Score: 21

```
let s={"a".."z"}in s

```

(M language reference)
> 1 votes

# Answer
# Z is for Z80Golf, 9 bytes + 7 = 16

```
00000000: 3e61 061a ff3c 10fc 76                   >a...<..v

```

Try it online!

According to the Web Archive, Z80Golf code golf machine was created (at least) in December 2007.

### Disassembly

```
start:
  ld a, 97  ; the char to print
  ld b, 26  ; loop count
loop:
  rst $38   ; 1-byte alias for putchar
  inc a
  djnz loop ; decrement b and jump to `loop` if nonzero
  halt      ; end program

```
> 1 votes

# Answer
# Z is for Zsh, 19 characters -\> Score: 22

19 character solution thanks to @GammaFunction.

```
<<<${(j::):-{a..z}}

```

Another 18 character solution using Perl.

```
perl -eprint\ a..z

```
> 1 votes

# Answer
# I is for Io, 31 characters -\> Score: 33

```
for($,65,90,$asCharacter print)

```
> 1 votes

# Answer
# F is for Fish, 16 bytes; score 20

```
"a"r:o1+:"{"=?;r

```
> 1 votes

# Answer
# F is for Forth (gforth), 26 + 5 = 31

```
'{ 'a [do] [i] emit [loop]

```

Try it online!

Two improvements over the submission by leancz 6 years ago:

* An ASCII char prefixed with a quote gives the ASCII value of that char. So `'{` saves a byte over `123`. `'a` is just for consistency.
* The looping words including `do` and `loop` can't be used in interpreted mode, but `gforth` provides interpreted versions surrounded with brackets like `[do]` and `[loop]`. If a function uses three or less such words, using interpreted mode saves some bytes, as illustrated below.

```
\ using compiled mode
: a '{ 'a do i emit loop ; a
\ using interpreted mode
'{ 'a [do] [i] emit [loop]

```
> 1 votes

# Answer
# P is for Pyth, 1 character -\> Score: 5

```
G

```

Try it out!

That's it - just 1 letter. This is how it works:

* The variable `G` is by default initialised to `abcdefghijklmnopqrstuvwxyz` in this language.
* By default, the value returned by a program is printed out to the standard output.
> 1 votes

# Answer
# ink, 26 bytes, score: 29

Glad to hear that newer languages are allowed.

```
abcdefghijklmnopqrstuvwxyz

```

Try it online!
> 1 votes

# Answer
# Jelly, 2 bytes, score: 7

Jelly has a built-in.

```
Øa

```

Try it online!
> 1 votes

# Answer
# Pyth, 1 byte, score: 5

Pyth has a shorter built-in than Jelly.

```
G

```

Try it online!
> 1 votes

# Answer
# Pip, 1 byte, score: 4

```
z

```

Try it online!
> 1 votes

# Answer
# V (vim), 3 bytes, score: 4

```
¬az

```

Try it online!
> 1 votes

# Answer
# Wren, 58 bytes

The iteration method

```
System.printAll((97..122).map{|i|String.fromCodePoint(i)})

```

Try it online!

# Wren, 42 bytes

The boring method

```
System.print("abcdefghijklmnopqrstuvwxyz")

```

Try it online!
> 1 votes

# Answer
# Befunge-93, 33 bytes

I thought I could beat Brachylog... never mind.

```
"a">:,1+:"{"-#v_@
   ^          <

```

Try it online!
> 1 votes

# Answer
# Husk, 4 bytes → Score: 8

```
…"ab

```

Try it online!
> 1 votes

# Answer
# Ly, 11 bytes -\> Score: 13

```
'Rrp['`+o]

```

Try it online!

## Explanation

```
'          Push 26
  R          0-range
   r         reverse stack
    p        Pop 0
     ['`+o] Output the whole stack, added by 97

```
> 1 votes

# Answer
# F is for Foo, 17 bytes, score: 20

```
&65>&26(-1<$c+1>)

```

Try it online!

Ties the Fish answer.
> 1 votes

# Answer
# DOS, x86, 10 bytes + 3 = 13

This answer is fundamentally the same as Peter Cordes' x86, but uses DOS for I/O and as the "framework" of sorts to be able to "print\[s\] the alphabet" per the challenge description.

One could attempt to make the case that since this uses DOS API for said I/O that it one-step higher level than just x86. After all, DOS is an operating system, programming API, interpreter and framework all rolled into one, right? Also most every submission here eventually gets compiled down to machine code eventually to run, so aren't we really considering the submission to be the highest level required to produce the desired output?

Okay, feel free to call this rationalization baloney. It's not shorter than Peter's earlier x86 so just thought I'd throw in another take, competing or not! :)

**Binary:**

```
00000000: b061 cd29 403c 7a7e f9c3                 .a.)@<z~..

```

**Listing:**

```
B0 61       MOV  AL, 'a'        ; start at 'a'
    CLOOP:
CD 29       INT  29H            ; write AL to console
40          INC  AX             ; increment letter
3C 7A       CMP  AL, 'z'        ; is <= 'z'?
7E F9       JLE  CLOOP          ; if so, keep looping
C3          RET                 ; return to DOS

```

*And yes "DOS" can be considered a generic term for other different non-IBM PC Disk Operating Systems. However Wikipedia's entry for "DOS" specifically refers to IBM DOS and describes DOS as "a common shorthand for disk-based operating systems on IBM PC compatibles".*
> 1 votes

# Answer
## Ni, 13 bytes, score: 15

```
#61>#1a{<!+>}

```

Try (the snippet) online!

## Explanation

```
#61           Set Current as 'a'
   >          Move the pointer right
    #1a       Set current as 26
       {      Repeat 26 times:
        <         Move left
         !        Print the letter
          +       Increment the letter
           >      Move right
            }     (Automatically decrement counter)

```
> 1 votes

# Answer
## , 3 bytes (score: 4)

Near built-in solution, intended to beat Wake.

```
'zk

```

## Explanation

```
'z   Push the character z
  k  Generate a downwards character range for that character.

```
> 1 votes

# Answer
# Q is for QuadR, 26 bytes, Score: 31

```
abcdefghijklmnopqrstuvwxyz

```

Try it online!
> 1 votes

# Answer
# V for Vyxal, 2 bytes, score 2+5=7

```
ka

```

Try it Online!

Dunno someone has posted this already
> 1 votes

# Answer
# K is for K (ngn/k), 9 bytes -\> Score: 18

```
`c$97+!26

```

Try it online!

Bruh.
> 1 votes

# Answer
# Fig, \\$2\log\_{256}(96)\approx\\$ 1.646 bytes + 3 = 4.646

```
ca

```

Try it online!
> 1 votes

# Answer
# N is for Nibbles, 2.5 bytes (5 nibbles) + 7 = score 9.5

```
|@\$l

```

Attempt This Online!

```
|           # filter
 @          # printable ASCII characters:
  \         #   is the character
   $        #   of each of them
    l       #   a lowercase letter?

```
> 1 votes

# Answer
# Y is for , score 30 (29 bytes)

```
"abcdefghijklmnopqrstuvwxyz"p

```

Try it online by copy-pasting the code above and clicking the `timeout run` button.

**Explanation:**

```
"abcdefghijklmnopqrstuvwxyz"  # Push all characters between the "-quotes to the stack
                            p # Print the entire stack to STDOUT

```
> 1 votes

# Answer
# M is for MATL, 3 bytes, Score 7

```
2Y2

```

Try it online!
> 1 votes

# Answer
# Q is for QuadR, 8 bytes, score: 13

```
819⌶⎕A⋄⍵

```

Try it online!

## Explanation

Lowercase (`819⌶` \- "BIg" without a boolean is un-BIg) the uppercase alphabet (`⎕A`). The  avoids any additional output, and the  means this line should be run as code, rather than as a regex transformation.

---

# QuadR, 4 bytes, score: 9

I didn't realise it was allowed to use uppercase alphabet, which simplifies this greatly...

```
⎕A⋄⍵

```

Try it online!
> 1 votes

# Answer
## vimscript

What does output mean?

Assuming output to the current vim buffer is ok:

```
:norm aabcdefghijklmnopqrstuvwxyz

```

Otherwise, output to stdout:

```
:!echo abcdefghijklmnopqrstuvwxyz

```
> 0 votes

# Answer
# PHP, 26 + 3 = 29

```
<?=implode('',range(a,z));

```
> 0 votes

# Answer
**AWK,33+3(Penalty)**

```
END{for(;i<26;)printf"%c",97+i++}

```
> 0 votes

# Answer
# JavaScript, 34 + 10 = 44

```
alert('abcdefghijklmnopqrstuvwxyz')

```
> 0 votes

# Answer
# H is for HTML -\> 4+31

```
<HTML/>abcdefghijklmnopqrstuvwxyz

```

*ps: browser will interpret the missing end tag*
> 0 votes

# Answer
# T is for TI-BASIC, 27 + 8 = 35

```
"ABCDEFGHIJKLMNOPQRSTUVWXYZ

```

Can be run from command line, as a standalone program, or called as a function.
> 0 votes

# Answer
## **S is for Scala, Score: 40**

```
print("abcdefghijklmnopqrstuvwxyz")

```
> 0 votes

# Answer
## Racket, 46 bytes (score 52)

```
(for((i 26))(display(integer->char(+ i 97))))

```
> 0 votes

# Answer
# B is for Bash, 25 bytes

```
echo {a..z}|tr -d ' '

```

(21 bytes of code plus 4 for the language name)
> 0 votes

# Answer
## R is for REXX, 15 characters → Score: 19

```
say xrange(a,z)

```
> 0 votes

# Answer
# U is for uBASIC, 36 bytes → Score: 42

```
1 PRINT "abcdefghijklmnopqrstuvwxyz"

```

Try it online!
> 0 votes

# Answer
# F is for FALSE, 15 bytes +5 = 20

```
97[$'{-][$,1+]#

```

Doesn't use any letters!

## Explanation:

```
97 {push 97 (ASCII for 'a')}
  [ {function start}
   $'{- {subtract '{' from the current letter}
       ] {function end}
        [ {function start}
         $, {print the current letter}
           1+ {add 1}
             ] {function end}
              # {while loop. Run the second function while the first doesn't return 0}

```
> 0 votes

# Answer
# V is for VBA, 28 + 3 = 31

Anonymous VBE immediate window function that takes no input and outputs `abcdefghijklmnopqrstuvwxyz` to the VBE immediate window.

The two solutions below are of equal length and produce the same output

```
For i=97To 122:?Chr(i);:Next

```

Or

```
?"abcdefghijklmnopqrstuvwxyz

```
> 0 votes

# Answer
# U is for uBASIC, 30 + 6 = 36

Anonymous function that takes no input and outputs `abcdefghijklmnopqrstuvwxyz`

```
0?"abcdefghijklmnopqrstuvwxyz"

```

Try it online!
> 0 votes

# Answer
# S is for SmileBASIC, 27 bytes + 10 = 37

```
FOR I=65TO 90?CHR$(I);
NEXT

```

Prints the alphabet in uppercase. (I'm not sure whether this is allowed, but other people are doing it so...)

Just 1 character shorter than the (even more) boring answer:

```
?"abcdefghijklmnopqrstuvwxyz

```
> 0 votes

# Answer
# I is for ICI, 37+3 bytes → 40

```
printf("abcdefghijklmnopqrstuvwxyz");

```
> 0 votes

# Answer
# I is for Io, 35+2 bytes → 37

```
"abcdefghijklmnopqrstuvwxyz"println

```
> 0 votes

# Answer
# C is for Common Lisp, Score 35 + 11 =\> 46

```
(princ"abcdefghijklmnopqrstuvwxyz")

```

Try it online!
> 0 votes

# Answer
# P is for PowerShell, 15 bytes+10 = 25

```
-join('a'..'z')

```

Try it online!

Uses the character range feature added in 6.0 to improve upon past answers.
> 0 votes

# Answer
# Canvas, 1 byte, score: 7

Try it online!
> 0 votes

# Answer
# CJam, 7 bytes, score: 11

Learnt this language just for solving this problem.

```
'{,'a,-

```

Try it online!
> 0 votes

# Answer
# Stax, 2 bytes, score: 6

Also, Stax has a built-in.

```
Va

```

Try it online!
> 0 votes

# Answer
# Gaia, 2 bytes, score: 6

```
₵a

```

Try it online!
> 0 votes

# Answer
# MathGolf, 1 byte, score: 9

Try it online!
> 0 votes

# Answer
# Japt, 2 bytes, score: 6

```
;C

```

Try it online!
> 0 votes

# Answer
# 05AB1E, 1 byte, score: 7

```
A

```

Try it online!
> 0 votes

# Answer
# Jsonnet (with `-S`), 37 characters, score: 44

```
std.repeat("%c",26)%std.range(97,122)

```

Sample run:

```
bash-5.0$ jsonnet -Se 'std.repeat("%c",26)%std.range(97,122)'
abcdefghijklmnopqrstuvwxyz

```
> 0 votes

# Answer
# C is for , 34 bytes + 1 = 35

```
c(i){for(i=26;i;)putchar(91-i--);}

```
> 0 votes

# Answer
# X is for XJam, 6 + 4 = 10

```
'[,65>

```

What is XJam, you may ask? It's a language I started creating earlier this year and gave up before doing anything really interesting. It technically does fulfill its design criteria though, which is to be a version of CJam which adapts to the informal specification in the xkcd comic . It accomplishes this by using a custom charset where Unicode characters representing variations on the letter X fill the top 32 slots in what's otherwise standard 7-bit ASCII. Those characters are then the only ones which can be used as variables. It also happens to be perfect for this challenge, beating the previous x answer by two. (Sorry Peter Cordes, that x86 answer was great!)

Credit where it's due, the code is taken from Lynn's answer on a different question here. It doesn't use variables so it ports over perfectly.
> 0 votes

# Answer
# Eso2D, 15 bytes + 5 = 20

```
2v
,>#1~5
@#,5<

```

Eso2D is a language starting with E that has a relatively short name and an instruction set very good for string construction that I found on the esolang wiki. This could probably be improved further, but it's more than enough for a new best E.

Explanation:

```
2v        Increment the accumulator by 97 and move down to the second row
,>#1~5    Loop (from wrapping): print num to char, add 50, check if > 170, decrement by 49 otherwise.
@#,5<     Once it hits 171, decrement by 49 and print one last time before stopping.

```
> 0 votes

# Answer
# Foo, 11 bytes, score 14

```
&65(91$c+1)

```

Try it online!

```
&65(91$c+1)

&65           # Set current cell to 'A'
   (91    )   # While current cell != 'Z'+1
      $c      # Print ASCII of current cell
        +1    # Increment current cell

```

Beats the previous Foo answer by not using another cell.
> 0 votes

# Answer
# P is for Pyt, 4 bytes

```
ɫ

```

Try it online!

Gotta love builtins
> 0 votes

# Answer
# T is for Thunno, 2 + 6 = 8

```
Az

```

Attempt This Online!
> 0 votes

# Answer
# G is for gs2, 1 + 3 = 4 bytes

```
à

```

Uses the CP437 encoding.

Hexdump:

`85`
> 0 votes

# Answer
# B is for BQN, 7 bytes + 3 = score 10

```
'a'+↕26

```

Try it at BQN REPL

```
    ↕26     # range from 0 to 25
   +        # add to
'a'         # character 'a'

```
> 0 votes

# Answer
# U is for Uiua, 6 bytes, Score 10

```
+@A⇡26

```

First Non-Vyxal answer
> 0 votes

# Answer
# E is for ESMin, 2 Bytes, Score 2+5 = 7

Try it online, firefox only
> 0 votes

# Answer
# O is for Ohm v2, 3 bytes, 6+3 = 9

```
αa,

```

Try it online!
> 0 votes

# Answer
# RProgN, 1 byte, 6+1=7

```
a

```

Try it online!
> 0 votes

# Answer
# Implicit, 7 bytes, 7+8=15

```
26¡"é64

```

Try it online!

```
26¡"é64
26¡      # range [1,26]
   "     # convert entire stack to ascii character
    é64  # increment each character by 64

```

Created with the help of Luminespire.
> 0 votes

---
Tags: code-challenge, kolmogorov-complexity
---


title: Find Recursively Prime Primes

text:
# Question
Title: Find Recursively Prime Primes
The Recursively Prime Primes is are sequence of primes such that

```
p(1) = 2
p(n) = the p(n-1)th prime

```

Here is an example of how one might calculate the 4th Recursively Prime Prime.

```
p(4) = the p(3)th prime
p(3) = the p(2)th prime
p(2) = the p(1)th prime
p(1) = 2
p(2) = the 2nd prime
p(2) = 3
p(3) = the 3rd prime
p(3) = 5
p(4) = the 5th prime
p(4) = 11

```

You should write a program or function that when given n, outputs the nth Recursively Prime Prime.

You may choose to use 0 based indexing if you wish in which case you must indicate so in your answer.

This is so the goal is to minimize your byte count.

---

# Test Cases

```
1 -> 2
2 -> 3
3 -> 5
4 -> 11
5 -> 31
6 -> 127
7 -> 709
8 -> 5381
9 -> 52711

```

---

Relevant OEIS entry: OEIS A007097

# Answer
> 16 votes
# Oasis, 3 bytes

The program is **0-indexed**. Code:

```
<q2

```

Uses the formula: **a(n) = nth\_prime(a(n-1) - 1)**, with the base case **a(0) = 2**.

Code explanation:

```
  2   = a(0)

<     # Decrement a(n - 1) to get a(n - 1) - 1
 q    # prime(a(n - 1) - 1)

```

Try it online!

# Answer
> 10 votes
# Mathematica, 16 bytes

```
Nest[Prime,1,#]&

```

Anonymous function. Takes a number as input and returns a number as output.

# Answer
> 8 votes
# Actually, 7 bytes

```
1@⌠DP⌡n

```

Try it online!

Explanation:

```
1@⌠DP⌡n
1        push 1
 @       swap 1 with n
  ⌠DP⌡n  do the following n times:
   DP      decrement, prime at index

```

# Answer
> 6 votes
# Jelly, ~~5~~ 4 bytes

*1 byte thanks to @Dennis.*

```
1ÆN¡

```

Try it online!

### Explanation

```
1        Starting with n = 1,
 ÆN      replace n by the nth prime
   ¡     (input) times.

```

# Answer
> 5 votes
# JavaScript (ES6), 71 bytes

```
p=(n,x=1)=>n?p(n-1,(N=y=>x?N(++y,x-=(P=z=>y%--z?P(z):z==1)(y)):y)(1)):x

```

Ungolfed, you have three separate recursive functions:

```
P=(n,x=n)=>n%--x?P(n,x):x==1
N=(n,x=1)=>n?N(n-P(++x),x):x
p=(n,x=1)=>n?p(n-1,N(x)):x

```
* `P` determines whether `n` is prime;
* `N` finds the `n`th prime;
* `p` recursively runs `N` on input `1` `n` times.

# Answer
> 4 votes
# MATL, 6 bytes

```
1i:"Yq

```

Try it online!

### Explanation

```
1      % Push 1
i      % Input n
:      % Range [1 2 ... N]
"      % For each (that is, do the following N times)
  Yq   %   k-th prime, where k is the input
       % End for each (implicit)
       % Display stack (implicit)

```

# Answer
> 3 votes
# R, ~~98~~ 93 bytes

*5 bytes thanks to @smci*

Here is a horribly inefficient recursive solution:

```
f<-function(m,n=1){j<-1;for(i in 1:n){j<-numbers::nextPrime(j)};a<-ifelse(m==0,j,f(m-1,j));a}

```

Test Output:

```
f(6)
[1] 127

f(10)        ### takes almost a minute... YIKES!!!
[1] 648391

```

# Answer
> 3 votes
# 05AB1E, 4 bytes

```
ÎF<Ø

```

Try it online!

### Explanation

```
ÎF<Ø
Î    # Push 0 and input
 F   # Do input times...
  <   # Decrement
   Ø  # Get the nth prime (0-indexed) with n being the top of the stack

```

# Answer
> 3 votes
# Husk, 6 bytes

```
!¡!İp2

```

Try it online!

Explanation:

```
!¡!İp2
 ¡           Make an infinite list by repeatedly applying a function
     2       Starting with 2
   İp        From the sequence of prime numbers
  !          Get the element at the given index (the previous number in the sequence)
!            Get the element at index (implicit input) in that infinite list

```

# Answer
> 2 votes
# Bash + common utilities, 55

Since we're doing recursive primes, here's a recursive answer:

```
((SHLVL-2<$1))&&primes 2|sed -n "`$0 $1`{p;q}"||echo 1

```

Since recursion level counting is based off the `$SHLVL` built-in variable, then the answer can be off if you're already a few shell levels deep. This is probably why this answer doesn't work on TIO.

---

If that's no good, then here's a more conventional answer:

# Bash + common utilities, 58

```
for((i=$1;i--;));{
n=`primes 2|sed -n "$n{p;q}"`
}
echo $n

```

Try it online.

# Answer
> 2 votes
# APL (Dyalog Extended), ~~10~~ 8 bytes

Saved 2 bytes thanks to Adám

```
⌂pco⍣⎕⊢1

```

Try it online!

applies the function `⌂pco` (nth prime) to 1 n times (n is taken through STDIN ()).

## Another previous solution, 10 bytes

```
⊢∘⌂pco/⍴∘2

```

Try it online!

`⍴∘2` makes a vector of n 2's, then `/` reduces using the train `⊢∘⌂pco`.  ignores its left argument, `pco` finds the nth prime, given n on the right. More generally, `⊢∘f/n⍴s` applies `f` `n-1` times to `s`.

# Answer
> 2 votes
# Vyxal, 5 bytes

```
1$(‹ǎ

```

Try it Online!

```
1$    # Push 1 and the input
  (   # Input times
   ‹ǎ # Decrement and get nth prime

```

# Answer
> 2 votes
# Factor \+ `math.primes.lists`, 57 bytes

```
: p ( m -- n ) [ 2 ] [ 1 - p 1 - lprimes lnth ] if-zero ;

```

Try it online!

## Explanation

Returns the 0-indexed member of the recursively-prime prime sequence.

* `: p ( m -- n ) ... ;` Start a new word definition named `p` with stack effect `( m -- n )`, declaring it takes one thing from the data stack and leaves one thing on the data stack.
* `[ 2 ] [ ... ] if-zero` Is the input `0`? Then return `2`. Otherwise, do `...`.
* `1 - p` Apply `p` to the input minus one.
* `1 - lprimes lnth` Return the nth prime number.

# Answer
> 1 votes
# Haskell, 58 bytes

1-indexed

```
f 1=2;f n=[x|x<-[2..],all((>)2.gcd x)[2..x-1]]!!(f(n-1)-1)

```

Try it online!

**Explanation:**

Uses the same 0-indexed prime-list access trick as Adnan's answer.
Essentially straight-up follows the specification otherwise.

```
f 1=2; -- base case
f n= -- main case
    [x|x<-[2..],all((>)2.gcd x)[2..x-1]]             -- list of all primes
    [x|x<-[2..],                                     -- consider all numbers
                               [2..x-1]              -- consider all smaller numbers
                all((>)2.gcd x)                      -- is coprime with them?
                    (>)2.                            -- 2 is greater than
                         gcd x                       -- gcd(x,lambda input)
                                        !!(f(n-1)-1) -- access the
                                                     -- f(n-1)-th 1-indexed prime

```

# Answer
> 1 votes
# Husk, 10 bytes

```
?K2ȯ!İp₀←ε

```

Try it online!

A recursive function.

# Answer
> 1 votes
# J-uby, 33 bytes

```
~(:-&(:**&(:take&Prime|:last)))&1

```

Attempt This Online!

## Explanation

```
~(:- & (:** & (:take & Prime | :last))) & 1
               :take & Prime | :last         # nth prime
~(:- & (:** & (                     ))) & 1  # Apply to 1 input times

```

Created with the help of Luminespire.

# Answer
> 0 votes
# Wonder, 23 bytes

```
p\.{1\2@:^(- p -#0 1)1P

```

1-indexed. Usage:

```
p\.{1\2@:^(- p -#0 1)1P}; p 3

```

# Explanation

```
p\.{                #. Pattern matching syntax
  1\2               #. Base case p(1)=2
  @:^(- p -#0 1)1P  #. Other cases p(n)=nthprime(p(n-1)-1)
                    #. nthprime is 0-indexed
}                   #. Trailing bracket is optional in this case

```

# Answer
> 0 votes
# Python 3, 85 bytes

```
p=lambda x:[i for i in range(2,5*x**x)if all(i%j for j in range(2,i))][x and~-p(x-1)]

```

Try it online!

Uses 0-indexing.

# Answer
> 0 votes
# PARI/GP, 34 bytes

```
f(n)={r=1;for(i=1,n,r=prime(r));r}

```

Attempt This Online!

---
Tags: code-golf, primes, integer
---