4 ms·
FRACTRAN - the esoteric programming language invented by John H Conway
- dalke 15y agoThat was neat. Here's an implementation in Python: # Python implementation of Conway's prime formula for FRACTRAN # The output is the sequence A034785. from fractions import Fraction as F terms = [F(17, 91), F(78, 85), F(19, 51), F(23, 38), F(29, 33), F(77, 29), F(95, 23), F(77, 19), F(1, 17), F(11, 13), F(13, 11), F(15, 14), F(15, 2), F(55, 1)] n = 2 print n while 1: for i, f in enumerate(terms): fn = f * n if fn.denominator == 1: n = fn.numerator print n break else: break