User:Thebigh/mysandbox: Difference between revisions

expand, more to come
(→‎Integer Sequence: -concise is good)
(expand, more to come)
Line 17:
Given the number 1 as input the following program will, as its (3n-2)th step, produce the number 2^n.
<lang fractran> {2/3, 9/2, 2/1}</lang>
 
==Logical operations==
It's not so hard to code up all sixteen possible two-input logic gates, so here they are. The input is 2^a 3^b where a,b are zero or one and the output is 5^1 for true and 5^0 for false. Gates that return true when all their inputs are false additionally require the flag 11 to be set as input (ie 2^a*3^b*11)- any FRACTRAN program with the number 1 as input either stops without doing anything or loops forever.
 
<lang fractran>
{5/6, 1/2, 1/3} AND gate
{5/6, 5/2, 5/3} OR gate
{1/22, 5/11} NOT gate (uses 11 as a halt flag, result of 2^a*11 is 5^not(a))
{1/6, 5/2, 5/3} XOR gate
{1/66, 5/22, 5/33, 5/11} NAND gate (needs 11 flag)
{5/66, 1/22, 1/33, 5/11} NXOR gate (needs flag)
{1/66, 1/22, 1/33, 5/11} NOR gate (needs flag)
 
so much for all the commonly encountered ones, but there's still another ten to go
 
{1/2, 1/3} ZERO gate, returns false regardless of its input
</lang>
 
 
==Sort three variables==
781

edits