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
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.
| Start | Ends in the cycle |
|---|---|
| 1234 | 28, 48, 7, 6, 9 |
| 0 | 28, 48, 7, 6, 9 |
| 4 | 4, 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.
The first line is the specification's own example, 27 numbers down to the 28 that comes back.
Further
See also
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 preparationSource
- 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