User:Thebigh/mysandbox: Difference between revisions

From Rosetta Code
Content added Content deleted
(add the simplest task)
(...actually, THIS is the simplest program (:)
Line 8: Line 8:
</lang>
</lang>
The output is 2^(a+b)
The output is 2^(a+b)

==Empty program==

A list of no fractions does nothing, then immediately stops.
<lang fractran>{}</lang>


==Integer Sequence==
==Integer Sequence==

Revision as of 15:58, 23 November 2021

Some FRACTRAN programs in case we ever have a category for it

A+B

Input a number of the form 2^a 3^b <lang fractran> {2/3} </lang> The output is 2^(a+b)

Empty program

A list of no fractions does nothing, then immediately stops. <lang fractran>{}</lang>

Integer Sequence

<lang fractran> 1 {2/3, 9/2, 2/1}</lang>

Output:

2^0 2^1 3^2 2 x 3 2^2 2 x 3^2 2^2 x 3 2^3 ...

Regarding only the powers of two, we get 1,2,4,8,16, etc.

Sort three variables

FRACTRAN's only data type is positive integers. Suppose (a,b,c) are the integers to be sorted. Give the following as input: 2^a 3^b 5^c <lang fractran> {1001/30, 143/6, 143/10, 143/15, 13/2, 13/3, 13/5} </lang> Returns 7^A 11^B 13^C where (A,B,C) are (a,b,c) in ascending order.