esolang

Preparation

A program is one number. It turns into the next one until a number comes back.

Hakerh400, 2023 · Turing complete: unknown · ●○○ easy · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: 1234 2232 3456 1475 1794 2365 1764 3655 4026 4480 603 550 624 25 66 135 108 143 12 16 45 28 48 7 6 9 28

The idea

Hakerh400 made Preparation in 2023. The whole source is a natural number z. Each step takes the smallest k whose square is above the current number, and multiplies k by the gap between that square and the number. The output is every number on the way, up to the first one that repeats. The author conjectures that every start ends in a cycle, so every program stops.

The machine

a(0) is z, and a(i+1) is k(k² − a(i)) with k the ceiling of the square root of a(i) + 1. For 1234 that is k = 36, 36² = 1296, 1296 − 1234 = 62, and 36 × 62 = 2232.

StartEnds in the cycle
123428, 48, 7, 6, 9
028, 48, 7, 6, 9
44, 15

Of the starts from 0 to 10,000, 8,636 end in the cycle through 28 and 1,201 in the cycle 4, 15. The longest run in that range starts at 4924 and prints 94 numbers. Each number is printed on its own line, and the number that comes back is printed once more, as the listing ends with it.

Example

The first line is the specification's own example, 27 numbers down to the 28 that comes back.
Expected: 0 1 6 9 28 48 7 6
Expected: 3 2 4 15 4

The first line is the specification's own example, 27 numbers down to the 28 that comes back.

Further

String-rewriting paradigm

Write your own in Run Convert a program from Preparation

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run preparation -e '28'
shib manual preparation

Source

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

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

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