FRACTRAN
From Wikipedia, the free encyclopedia
FRACTRAN is a Turing-complete functional esoteric programming language invented by the mathematician John Conway. FRACTRAN programs are given as a list of fractions which are applied to a single argument p as follows:
- multiply p by each fraction ƒ in the list in turn until pƒ is an integer; replace p by pƒ and repeat;
- halt if no member of the list produces an integer when multiplied by p. This algorithm can be implemented very simply; for example, in J, a basic FRACTRAN interpretor might be
(*{~1 i.~[@(=<.)@:*)
.
Conway gave an interesting formula for primes in FRACTRAN:
Starting with p=2, this FRACTRAN program generates the following sequence of integers:
After 2, this sequence contains the following powers of 2:
which are the prime powers of 2.
[edit] See also
[edit] Further reading
- Conway, John H.; Guy, Richard K. (1996). The Book of Numbers. Springer-Verlag New York, Inc.. ISBN 038797993X.
- Havil, Julian (2007). Nonplussed!. Princeton University Press. ISBN 0691120560.
[edit] External links
- "Prime Number Pathology: Fractran"
- FRACTRAN. Mathworld. Retrieved on August 10, 2005.
- Prime Number Pathology
- FRACTRAN -(Esolang wiki)