Lably
Skip to content

Related on Lably

Through Sequence, Fraction and Prime number

  1. for the first fraction f in the list for which nf is an integer, replace n by nf
  2. repeat this rule until no fraction in the list produces an integer when multiplied by n, then halt.

Conway 1987 gives the following FRACTRAN program, called PRIMEGAME, which finds successive prime numbers:

(1791,7885,1951,2338,2933,7729,9523,7719,117,1113,1311,152,17,551)

Starting with n=2, this FRACTRAN program generates the following sequence of integers:

  • 2, 15, 825, 725, 1925, 2275, 425, 390, 330, 290, 770, ... (sequence A007542 in the OEIS)

After 2, this sequence contains the following powers of 2:

22=4,23=8,25=32,27=128,211=2048,213=8192,217=131072,219=524288,… (sequence A034785 in the OEIS)

The exponent part of these powers of two are primes, 2, 3, 5, etc.

Understanding a FRACTRAN program

A FRACTRAN program can be seen as a type of register machine where the registers are stored in prime exponents in the argument n.

Using Gödel numbering, a positive integer n can encode an arbitrary number of arbitrarily large positive integer variables. The value of each variable is encoded as the exponent of a prime number in the prime factorization of the integer. For example, the integer

60=22×31×51

represents a register state in which one variable (which we will call v2) holds the value 2 and two other variables (v3 and v5) hold the value 1. All other variables hold the value 0.

A FRACTRAN program is an ordered list of positive fractions. Each fraction represents an instruction that tests one or more variables, represented by the prime factors of its denominator. For example:

f1=2120=3×722×51

tests v2 and v5. If v2≥2 and v5≥1, then it subtracts 2 from v2 and 1 from v5 and adds 1 to v3 and 1 to v7. For example:

60⋅f1=22×31×51⋅3×722×51=32×71

Since the FRACTRAN program is just a list of fractions, these test-decrement-increment instructions are the only allowed instructions in the FRACTRAN language. In addition the following restrictions apply:

  • Each time an instruction is executed, the variables that are tested are also decremented.
  • The same variable cannot be both decremented and incremented in a single instruction (otherwise the fraction representing that instruction would not be in its lowest terms). Therefore each FRACTRAN instruction consumes variables as it tests them.
  • It is not possible for a FRACTRAN instruction to directly test if a variable is 0 (However, an indirect test can be implemented by creating a default instruction that is placed after other instructions that test a particular variable.).

Sign in to keep reading

3 more chapters are free with a Lably account.

More in Scientists, inventors, and mathematicians