Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Fractran/Fermat/fractran.fermat
Normal file
26
Task/Fractran/Fermat/fractran.fermat
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
Func FT( arr, n, m ) =
|
||||
;{executes John H. Conway's FRACTRAN language for a program stored in [arr], an}
|
||||
;{input integer stored in n, for a maximum of m steps}
|
||||
;{To allow the program to run indefinitely, give it negative or noninteger m}
|
||||
exec:=1; {boolean to track whether the program needs to halt}
|
||||
len:=Cols[arr]; {length of the input program}
|
||||
while exec=1 and m<>0 do
|
||||
m:-;
|
||||
!!n; {output the memory}
|
||||
i:=1; {index variable}
|
||||
exec:=0;
|
||||
while i<=len and exec=0 do
|
||||
nf:=n*arr[i];
|
||||
if Denom(nf) = 1 then
|
||||
n:=nf; {did we find an instruction to execute?}
|
||||
exec:=1
|
||||
fi;
|
||||
i:+;
|
||||
od;
|
||||
od;
|
||||
.;
|
||||
|
||||
;{Here is the program to run}
|
||||
[arr]:=[( 17/91,78/85,19/51,23/38,29/33,77/29,95/23,77/19,1/17,11/13,13/11,15/14,15/2,55/1 )];
|
||||
|
||||
FT( [arr], 2, 20 );
|
||||
Loading…
Add table
Add a link
Reference in a new issue