esolang

Primes

Brainfuck written in numbers, where only the count of prime factors matters.

Meloons, 2021 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: Hello World!

The idea

Meloons made Primes in 2021, after brainfuck. A program is a list of numbers. Each number is factored, and the count of its prime factors, repeats included, picks the instruction. 143 is 11 times 13, so it has 2 factors and moves the pointer right. 32 is 2 to the fifth, so it adds 1.

Read the story

So any one program can be written in countless ways. The specification gives its Hello World twice, once in powers of two and once in numbers like 3675 and 11858 that factor to the same counts.

The memory is a grid, and the pointer moves up and down as well as left and right.

The machine

FactorsDoesSmallest number
0Halt0 or 1
1 2Pointer left, right2, 4
3 4Pointer up, down8, 16
5 6Add 1, subtract 132, 64
7 8Start loop, end loop128, 256
9 10Print a byte, read a byte512, 1024
11Set the cell to 02048

Loops work as brainfuck's [ and ]. The specification leaves the cell size open. Its 99 bottles program only ends when cells are bytes that wrap, so they are bytes.

Example

The Hello World in powers of two.

The Hello World in powers of two. The pointer only goes up (8) and down (16), so it uses one column of the grid.

Read two bytes into neighbouring cells and print them. 1024 reads, 143 moves right, 2 moves left and 512 prints.

Expected: ok

Patterns it teaches

Further

Primes builds on Brainfuck.

Brainfuck derivatives

Cell-based

Write your own in Run Convert a program from Primes

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: primes.

Command line

shib run primes program.txt

The program is long; save it as program.txt first.

shib manual primes

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/primes.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org