| Bytes | Lang | Time | Link |
|---|---|---|---|
| 000 | CASIO BASIC CASIO fx9750GIII | 250507T215107Z | madeforl |
| 007 | Python 2 | 200410T102701Z | Command |
| 038 | Pascal | 240404T000035Z | Kai Burg |
| 008 | CellTail | 221005T190157Z | mousetai |
| 001 | Noxan | 220304T124625Z | Noxan Bo |
| 003 | ><> | 220127T162829Z | Fmbalbue |
| 002 | Gol><> | 220127T162806Z | Fmbalbue |
| 004 | Uselesslang | 211225T154243Z | Fmbalbue |
| 001 | J | 200411T133029Z | PkmnQ |
| 004 | naz | 200411T045240Z | sporebal |
| 008 | Malbolge | 200410T185858Z | dingledo |
| 003 | TrumpScript | 200410T152303Z | ElPedro |
| 000 | Visual Basic .NET VBC | 200410T155906Z | the defa |
| 001 | Enlist | 200410T154618Z | ElPedro |
| 011 | Lost | 200410T124443Z | Kevin Cr |
| 772 | Lenguage | 200410T122514Z | Kevin Cr |
| 012 | Nandy | 200410T103855Z | user9206 |
| 015 | Python 3 without literals | 200410T120053Z | PkmnQ |
| 012 | C gcc | 200410T110659Z | Noodle9 |
| 012 | AWK | 200410T112452Z | Noodle9 |
| 003 | += | 200410T112301Z | user9206 |
| 004 | JavaScript Node.js | 200410T112039Z | Command |
| 006 | Bash | 200410T111456Z | Noodle9 |
| 007 | Python 3 | 200410T110431Z | Noodle9 |
| 010 | Whitespace | 200410T103859Z | Kevin Cr |
| 004 | Java 8 | 200410T103606Z | Kevin Cr |
| 003 | Width | 200410T103102Z | user9206 |
| 014 | brainfuck | 200410T102533Z | Command |
| 001 | 05AB1E | 200410T101749Z | Command |
CASIO BASIC (CASIO fx-9750GIII), 0 bytes (?!?!?!)
2
Yes. That is 0 bytes.
I have no clue how this works.
Pascal, 38 characters
Are there any restrictions on the utilized number system? 🤔
In Pascal, string literals cannot contain arbitrary data.
For the following program to work, the character 𒐖 must be a permissible value of the implementation‑defined set of char values.
program p(output);begin write('𒐖')end.
The whole deal using Standard Pascal (ISO standard 7185, level 0 sufficient) could look like this:
{ This program depends on `output`.
I. e. `./a.out >&-` (shell syntax closing output) should/could fail. }
program evenPrimeNumbers(output);
{ Pascal is a strongly typed and awesome programming language. }
type
{ A variable of type `natural` can only assume
integral values in the range `1` through `maxInt` inclusive. }
natural = 1‥maxInt;
naturals = set of natural;
{ In Standard Pascal as defined by ISO standard 7185
functions cannot return structured value types.
Therefore `divisors` returns a pointer data type. }
naturalsReference = ↑naturals;
{ In Standard Pascal as defined by ISO standard 7185 there is a strict
order `label` → `const` → `type` → `var` → routines → `begin … end`. }
var
primeNumberCandidate: natural;
{ Returns divisor ∣ dividend. }
function divides(divisor, dividend: integer): Boolean;
begin
{ Division by zero is undefined so do not attempt it. }
if divisor = 0 then
begin
{ In Pascal the result of a function is defined by
assigning a value to the implicitly defined (semi‑)variable
bearing the function’s name. }
divides ≔ false
end
else
begin
{ Modulo divisor must be positive. }
divides ≔ dividend mod abs(divisor) = 0
end
end;
{ Returns the set of all divisors of n. }
function divisors(n: natural): naturalsReference;
var
divisorCandidate: natural;
factors: naturalsReference;
begin
{ Allocate memory for factors and assign address to `factors`. }
new(factors);
{ Trivial divisors. }
factors↑ ≔ [1, n];
for divisorCandidate ≔ 2 to round(sqrt(n)) do
begin
if divides(divisorCandidate, n) then
begin
{ The plus sign (also) identifies the union of two sets. }
factors↑ ≔ factors↑ + [divisorCandidate]
end
end;
divisors ≔ factors
end;
{ Returns primality of n. }
function primality(n: natural): Boolean;
begin
{ Note the distinction between `≔` (becomes) and `=` (equals). }
primality ≔ divisors(n)↑ = [1, n]
end;
{ ─── MAIN ─── }
begin
for primeNumberCandidate ≔ 1 to maxInt do
begin
{ Skip primality test if it is not an even number. }
if not odd(primeNumberCandidate) then
begin
if primality(primeNumberCandidate) then
begin
writeLn(output, primeNumberCandidate)
end
end
end
end.
See also trial division algorithm on RosettaCode.
CellTail, 8 bytes
I=2;O=N;
Explanation:
I=2sets the initial state to 2.O=Nsets the output format to numbers.
I should really get around to setting up these things as flags.
TrumpScript, 3 bytes
a
b
The error message in the output contains all even prime numbers and no other numbers. Well no-one said the output couldn't include other non-numeric text.
The exception message is a bit special:
Exception: Trump will ensure that 'America is great'
As a (not very much) more serious effort (without errors):
TrumpScript, 36 bytes
say 1000002-1000000
America is great
Visual Basic .NET (VBC), 0 bytes
They added this neat function that an empty program outputs a list of the even primes via the exit code.
Enlist, 1 byte
2
Just picked a random language on TIO and it worked. Oh well, it's another language to add to the list.
Lost, 11 bytes
v<<>>
>(%2@
Try it online or verify that it's deterministic.
Explanation:
Explanation of the language in general:
Lost is a 2D path-walking language. Most 2D path-walking languages start at the top-left position and travel towards the right by default. Lost is unique however, in that both the start position AND starting direction it travels in is completely random. So making the program deterministic, meaning it will have the same output regardless of where it starts or travels, can be quite tricky.
A Lost program of 2 rows and 5 characters per row can have 40 possible program flows. It can start on any one of the 10 characters in the program, and it can start traveling up/north, down/south, left/west, or right/east.
In Lost you therefore want to lead everything to a starting position, so it'll follow the designed path you want it to. In addition, you'll usually have to clean the stack when it starts somewhere in the middle.
Explanation of the program:
All arrows will lead the path towards the > on the second line. From there, the program flow is as follows:
>: Travel in a east/right direction.(: Pop the top of the stack (and push it to the scope). This is to clean a potential 2 that was already pushed.%: Put the safety 'off'. In a Lost program, an@will terminate the program, but only when the safety is 'off'. When the program starts, the safety is always 'on' by default, otherwise a program flow starting at the exit character@would immediately terminate without doing anything. The%will turn this safety 'off', so when we now encounter an@the program will terminate (if the safety is still 'on', the@will be a no-op instead).2: Push a 2@: Terminate the program if the safety is 'off' (which it is at this point). After which all the values on the stack will be output implicitly with space separator, which in this case is just the2.
Note that the top line could have been v<<<<, but that the reversed part >> will wrap-around to the other side, making the path shorter and therefore the performance slightly better. The byte-count remains the same anyway, so why not.
Lenguage, 979,674,373,772 bytes
Unary, 2,063,923,527,196 bytes
Programs consists of 2063923527196 and 979674373772 amount of characters of your own choosing.
Port of CommandMaster's brainfuck answer.
Byte-counts generated by this program I wrote in 05AB1E.
Nandy, 12 bytes
-2 Thanks to Kevin Cruijssen.
::#oo>oo>o>o
Explanation
::# Generate a 1 bit
oo Output 1 twice
> Roll the stack
oo Output 0 twice
>o>o Output 1 and 0
This makes the binary codepoint of ASCII 2. 110010
C (gcc), 15 14 12 bytes
Saved a byte thanks to petStorm!!!
Saved 2 bytes thanks to Arnauld!!!
a;f(){a|=2;}
Whitespace, 10 bytes
[S S S T S N
_Push_2][T N
S T _Print_as_integer]
Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.
Try it online (with raw spaces, tabs and new-lines only).
Explanation in pseudo-code:
Integer n = 2
Print n as integer to STDOUT
Java 8, 4 bytes
v->2
Explanation:
v-> // Method with empty unused parameter and integer return-type
2 // Return 2
Width, 3 bytes
Curious and hoping to try it. Not short at all, since it's designed for restricted-source.
Unfortunately in Width, numbers don't have the privilege of being implicitly printed. :(
Gfm
Explanation
G Start a string
fm Codepoint 18 in the custom code page ('2')
Implicit end quote
Implicit print
brainfuck, 14 bytes
-[>+<-----]>-.
-[>+<-----]> is a script to generate 50 (which is the ascii code of 2) from https://esolangs.org/wiki/Brainfuck_constants#50, and then . outputs it